From: David ‘Bombe’ Roden Date: Wed, 12 Jan 2011 18:59:30 +0000 (+0100) Subject: Add methods to create new albums. X-Git-Tag: beta-freefall-0.6.2-1~116 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=9121102ba7eb40fbe404822ea6318658b90cb497 Add methods to create new albums. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e01ea45..6813493 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1487,6 +1487,40 @@ public class Core implements IdentityListener, UpdateListener { } /** + * Creates a new top-level album for the given Sone. + * + * @param sone + * The Sone to create the album for + * @return The new album + */ + public Album createAlbum(Sone sone) { + return createAlbum(sone, null); + } + + /** + * Creates a new album for the given Sone. + * + * @param sone + * The Sone to create the album for + * @param parent + * The parent of the album (may be {@code null} to create a + * top-level album) + * @return The new album + */ + public Album createAlbum(Sone sone, Album parent) { + Album album = new Album(); + synchronized (albums) { + albums.put(album.getId(), album); + } + album.setSone(sone); + if (parent != null) { + parent.addAlbum(album); + } + sone.addAlbum(album); + return album; + } + + /** * Starts the core. */ public void start() {