- public synchronized String getFingerprint() {
- StringBuilder fingerprint = new StringBuilder();
- fingerprint.append("Profile(");
- if (profile.getFirstName() != null) {
- fingerprint.append("FirstName(").append(profile.getFirstName()).append(')');
- }
- if (profile.getMiddleName() != null) {
- fingerprint.append("MiddleName(").append(profile.getMiddleName()).append(')');
- }
- if (profile.getLastName() != null) {
- fingerprint.append("LastName(").append(profile.getLastName()).append(')');
- }
- if (profile.getBirthDay() != null) {
- fingerprint.append("BirthDay(").append(profile.getBirthDay()).append(')');
- }
- if (profile.getBirthMonth() != null) {
- fingerprint.append("BirthMonth(").append(profile.getBirthMonth()).append(')');
- }
- if (profile.getBirthYear() != null) {
- fingerprint.append("BirthYear(").append(profile.getBirthYear()).append(')');
- }
- fingerprint.append(")");
-
- fingerprint.append("Posts(");
- for (Post post : getPosts()) {
- fingerprint.append("Post(").append(post.getId()).append(')');
- }
- fingerprint.append(")");
-
- List<Reply> replies = new ArrayList<Reply>(getReplies());
- Collections.sort(replies, Reply.TIME_COMPARATOR);
- fingerprint.append("Replies(");
- for (Reply reply : replies) {
- fingerprint.append("Reply(").append(reply.getId()).append(')');
- }
- fingerprint.append(')');
-
- List<String> likedPostIds = new ArrayList<String>(getLikedPostIds());
- Collections.sort(likedPostIds);
- fingerprint.append("LikedPosts(");
- for (String likedPostId : likedPostIds) {
- fingerprint.append("Post(").append(likedPostId).append(')');
- }
- fingerprint.append(')');
-
- List<String> likedReplyIds = new ArrayList<String>(getLikedReplyIds());
- Collections.sort(likedReplyIds);
- fingerprint.append("LikedReplies(");
- for (String likedReplyId : likedReplyIds) {
- fingerprint.append("Reply(").append(likedReplyId).append(')');
- }
- fingerprint.append(')');
-
- return fingerprint.toString();
- }
-
- //
- // OBJECT METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return id.hashCode();
- }