import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static net.pterodactylus.sone.data.Identified.GET_ID;
import java.net.MalformedURLException;
import java.util.Collection;
configuration.getStringValue(albumPrefix + "/Title").setValue(album.getTitle());
configuration.getStringValue(albumPrefix + "/Description").setValue(album.getDescription());
configuration.getStringValue(albumPrefix + "/Parent").setValue(album.getParent().equals(sone.getRootAlbum()) ? null : album.getParent().getId());
- configuration.getStringValue(albumPrefix + "/AlbumImage").setValue(album.getAlbumImage() == null ? null : album.getAlbumImage().getId());
+ configuration.getStringValue(albumPrefix + "/AlbumImage").setValue(album.getAlbumImage().transform(GET_ID).orNull());
}
configuration.getStringValue(sonePrefix + "/Albums/" + albumCounter + "/ID").setValue(null);
import net.pterodactylus.sone.database.ImageBuilder;
import com.google.common.base.Function;
+import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
*/
List<Image> getImages();
- /**
- * Returns the album image of this album, or {@code null} if no album image has
- * been set.
- *
- * @return The image to show when this album is listed
- */
- Image getAlbumImage();
+ Optional<Image> getAlbumImage();
/**
* Returns whether this album contains any other albums or images.
package net.pterodactylus.sone.data.impl;
+import static com.google.common.base.Optional.absent;
+import static com.google.common.base.Optional.fromNullable;
import static com.google.common.base.Preconditions.checkState;
import java.util.ArrayList;
}
@Override
- public Image getAlbumImage() {
+ public Optional<Image> getAlbumImage() {
if (albumImage == null) {
- return null;
+ return absent();
}
- return Optional.fromNullable(images.get(albumImage)).or(images.values().iterator().next());
+ return fromNullable(fromNullable(images.get(albumImage)).or(images.values().iterator().next()));
}
@Override
}
backlinks.add(0, new Link("imageBrowser.html?sone=" + album.getSone().getId(), SoneAccessor.getNiceName(album.getSone())));
return backlinks;
+ } else if ("albumImage".equals(member)) {
+ return album.getAlbumImage().orNull();
}
return super.get(templateContext, object, member);
}