Change album ID to be unique, add internal ID
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AlbumImpl.java
index fa1538d..6a45187 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.UUID;
 
 import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.IdBuilder;
 import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Sone;
 
@@ -46,6 +47,8 @@ import com.google.common.hash.Hashing;
  */
 public class AlbumImpl implements Album {
 
+       private final IdBuilder idBuilder = new IdBuilder();
+
        /** The ID of this album. */
        private final String id;
 
@@ -95,6 +98,11 @@ public class AlbumImpl implements Album {
 
        @Override
        public String getId() {
+               return idBuilder.buildId(sone.getId(), id);
+       }
+
+       @Override
+       public String getInternalId() {
                return id;
        }
 
@@ -134,7 +142,7 @@ public class AlbumImpl implements Album {
                checkArgument(equals(album.getParent()), "album must belong to this album");
                int oldIndex = albums.indexOf(album);
                if (oldIndex <= 0) {
-                       return null;
+                       return album;
                }
                albums.remove(oldIndex);
                albums.add(oldIndex - 1, album);
@@ -148,7 +156,7 @@ public class AlbumImpl implements Album {
                checkArgument(equals(album.getParent()), "album must belong to this album");
                int oldIndex = albums.indexOf(album);
                if ((oldIndex < 0) || (oldIndex >= (albums.size() - 1))) {
-                       return null;
+                       return album;
                }
                albums.remove(oldIndex);
                albums.add(oldIndex + 1, album);