X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FAlbumImpl.java;h=3ec362f4cfa517dcc7825ee921b1ac16abb67a7d;hb=03cec6a6772c2d836d94864adddaf544cbe9d72f;hp=123fe75798207d6c66d008cbc030b8ded541d7c6;hpb=91b8268946412b35bcce5b4406106ecd4cb58e3c;p=Sone.git
diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java
index 123fe75..3ec362f 100644
--- a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java
+++ b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java
@@ -1,5 +1,5 @@
/*
- * Sone - AlbumImpl.java - Copyright © 2011â2015 David Roden
+ * Sone - AlbumImpl.java - Copyright © 2011â2019 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@ import static com.google.common.base.Optional.absent;
import static com.google.common.base.Optional.fromNullable;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.ArrayList;
import java.util.HashMap;
@@ -41,8 +42,6 @@ import com.google.common.hash.Hashing;
/**
* Container for images that can also contain nested {@link AlbumImpl}s.
- *
- * @author David âBombeâ Roden
*/
public class AlbumImpl implements Album {
@@ -53,13 +52,13 @@ public class AlbumImpl implements Album {
private final Sone sone;
/** Nested albums. */
- private final List albums = new ArrayList();
+ private final List albums = new ArrayList<>();
/** The image IDs in order. */
- private final List imageIds = new ArrayList();
+ private final List imageIds = new ArrayList<>();
/** The images in this album. */
- private final Map images = new HashMap();
+ private final Map images = new HashMap<>();
/** The parent album. */
private Album parent;
@@ -102,7 +101,7 @@ public class AlbumImpl implements Album {
@Override
public List getAlbums() {
- return new ArrayList(albums);
+ return new ArrayList<>(albums);
}
@Override
@@ -154,7 +153,7 @@ public class AlbumImpl implements Album {
@Override
public List getImages() {
- return new ArrayList(Collections2.filter(Collections2.transform(imageIds, new Function() {
+ return new ArrayList<>(Collections2.filter(Collections2.transform(imageIds, new Function() {
@Override
@SuppressWarnings("synthetic-access")
@@ -298,28 +297,28 @@ public class AlbumImpl implements Album {
@Override
public String getFingerprint() {
Hasher hash = Hashing.sha256().newHasher();
- hash.putString("Album(");
- hash.putString("ID(").putString(id).putString(")");
- hash.putString("Title(").putString(title).putString(")");
- hash.putString("Description(").putString(description).putString(")");
+ hash.putString("Album(", UTF_8);
+ hash.putString("ID(", UTF_8).putString(id, UTF_8).putString(")", UTF_8);
+ hash.putString("Title(", UTF_8).putString(title, UTF_8).putString(")", UTF_8);
+ hash.putString("Description(", UTF_8).putString(description, UTF_8).putString(")", UTF_8);
/* add nested albums. */
- hash.putString("Albums(");
+ hash.putString("Albums(", UTF_8);
for (Album album : albums) {
- hash.putString(album.getFingerprint());
+ hash.putString(album.getFingerprint(), UTF_8);
}
- hash.putString(")");
+ hash.putString(")", UTF_8);
/* add images. */
- hash.putString("Images(");
+ hash.putString("Images(", UTF_8);
for (Image image : getImages()) {
if (image.isInserted()) {
- hash.putString(image.getFingerprint());
+ hash.putString(image.getFingerprint(), UTF_8);
}
}
- hash.putString(")");
+ hash.putString(")", UTF_8);
- hash.putString(")");
+ hash.putString(")", UTF_8);
return hash.hash().toString();
}