- public List<Image> getImages() {
- return new ArrayList<Image>(Collections2.filter(Collections2.transform(imageIds, new Function<String, Image>() {
-
- @Override
- @SuppressWarnings("synthetic-access")
- public Image apply(String imageId) {
- return images.get(imageId);
- }
- }), Predicates.notNull()));
- }
-
- /**
- * Adds the given image to this album.
- *
- * @param image
- * The image to add
- */
- public void addImage(Image image) {
- checkNotNull(image, "image must not be null");
- checkNotNull(image.getSone(), "image must have an owner");
- checkArgument(image.getSone().equals(sone), "image must belong to the same Sone as this album");
- if (image.getAlbum() != null) {
- image.getAlbum().removeImage(image);
- }
- image.setAlbum(this);
- if (imageIds.isEmpty() && (albumImage == null)) {
- albumImage = image.getId();
- }
- if (!imageIds.contains(image.getId())) {
- imageIds.add(image.getId());
- images.put(image.getId(), image);
- }
- }