- public void setOptions(Options options) {
- this.options = options;
- }
-
- //
- // FINGERPRINTABLE METHODS
- //
-
- /** {@inheritDoc} */
- @Override
- public synchronized String getFingerprint() {
- Hasher hash = Hashing.sha256().newHasher();
- hash.putString(profile.getFingerprint());
-
- hash.putString("Posts(");
- for (Post post : getPosts()) {
- hash.putString("Post(").putString(post.getId()).putString(")");
- }
- hash.putString(")");
-
- List<PostReply> replies = new ArrayList<PostReply>(getReplies());
- Collections.sort(replies, Reply.TIME_COMPARATOR);
- hash.putString("Replies(");
- for (PostReply reply : replies) {
- hash.putString("Reply(").putString(reply.getId()).putString(")");
- }
- hash.putString(")");
-
- List<String> likedPostIds = new ArrayList<String>(getLikedPostIds());
- Collections.sort(likedPostIds);
- hash.putString("LikedPosts(");
- for (String likedPostId : likedPostIds) {
- hash.putString("Post(").putString(likedPostId).putString(")");
- }
- hash.putString(")");
-
- List<String> likedReplyIds = new ArrayList<String>(getLikedReplyIds());
- Collections.sort(likedReplyIds);
- hash.putString("LikedReplies(");
- for (String likedReplyId : likedReplyIds) {
- hash.putString("Reply(").putString(likedReplyId).putString(")");
- }
- hash.putString(")");
-
- hash.putString("Albums(");
- for (Album album : rootAlbum.getAlbums()) {
- if (!Album.NOT_EMPTY.apply(album)) {
- continue;
- }
- hash.putString(album.getFingerprint());
- }
- hash.putString(")");
-
- return hash.hash().toString();
- }
-
- //
- // INTERFACE Comparable<Sone>
- //
-
- /** {@inheritDoc} */
- @Override
- public int compareTo(Sone sone) {
- return NICE_NAME_COMPARATOR.compare(this, sone);
- }
-
- //
- // OBJECT METHODS
- //
-
- /** {@inheritDoc} */
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof Sone)) {
- return false;
- }
- return ((Sone) object).id.equals(id);
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return getClass().getName() + "[identity=" + identity + ",requestUri=" + requestUri + ",insertUri(" + String.valueOf(insertUri).length() + "),friends(" + friendSones.size() + "),posts(" + posts.size() + "),replies(" + replies.size() + "),albums(" + getRootAlbum().getAlbums().size() + ")]";
- }