From: David ‘Bombe’ Roden Date: Thu, 19 Apr 2012 14:11:47 +0000 (+0200) Subject: Load an artist’s groups lazily. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=442daa4c3aafcc8398ab52e7e475f3c28c5e7caa;p=demoscenemusic.git Load an artist’s groups lazily. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 85f35fa..7e74ea9 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -202,10 +202,31 @@ public class DataManager { } }); + private final Memoizer groupsMemoizer = new Memoizer(new Callable() { + + @Override + public Void call() throws Exception { + if (!hasValue("groups")) { + value("groups", Collection.class).set(getGroupsByArtist(id())); + } + return null; + } + + }); + public LazyArtist(String id) { super(id); } + /** + * {@inheritDoc} + */ + @Override + public Collection groups() { + groupsMemoizer.get(); + return super.groups(); + } + public Collection tracks() { tracksMemoizer.get(); return super.tracks();