package net.pterodactylus.sone.database;
+import java.util.List;
+
import net.pterodactylus.sone.data.Album;
import com.google.common.base.Optional;
*/
Optional<Album> getAlbum(String albumId);
+ List<Album> getAlbums(Album parent);
+
}
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.FluentIterable.from;
+import static java.util.Collections.emptyList;
import static net.pterodactylus.sone.data.Sone.LOCAL_SONE_FILTER;
import java.util.ArrayList;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
+import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
}
}
+ @Override
+ public List<Album> getAlbums(Album parent) {
+ lock.readLock().lock();
+ try {
+ return from(albumChildren.get(parent.getId())).transformAndConcat(getAlbum()).toList();
+ } finally {
+ lock.readLock().unlock();
+ }
+ }
+
//
// ALBUMSTORE METHODS
//
}
}
+ private Function<String, Iterable<Album>> getAlbum() {
+ return new Function<String, Iterable<Album>>() {
+ @Override
+ public Iterable<Album> apply(String input) {
+ return (input == null) ? Collections.<Album>emptyList() : getAlbum(input).asSet();
+ }
+ };
+ }
+
}