hw3: convert class members to final where possible, make Photo a record class

This commit is contained in:
2025-03-24 23:28:39 -07:00
parent 31302dd0d5
commit f8b38bae8f
8 changed files with 15 additions and 58 deletions

View File

@@ -8,7 +8,7 @@ import java.util.List;
public class SortByDate implements SortingStrategy<Photo> {
@Override
public List<Photo> sort(List<Photo> photos) {
photos.sort(Comparator.comparing(Photo::getDateAdded));
photos.sort(Comparator.comparing(Photo::dateAdded));
return photos;
}
}

View File

@@ -8,7 +8,7 @@ import java.util.List;
public class SortByName implements SortingStrategy<Photo> {
@Override
public List<Photo> sort(List<Photo> photos) {
photos.sort(Comparator.comparing(Photo::getName));
photos.sort(Comparator.comparing(Photo::name));
return photos;
}
}

View File

@@ -8,7 +8,7 @@ import java.util.List;
public class SortBySize implements SortingStrategy<Photo> {
@Override
public List<Photo> sort(List<Photo> photos) {
photos.sort(Comparator.comparing(Photo::getFileSize));
photos.sort(Comparator.comparing(Photo::fileSize));
return photos;
}
}