- 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);
- }
- }