package net.pterodactylus.sone.data;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.UUID;
*
* @return All replies to this post
*/
- public Set<Reply> getReplies() {
- return Collections.unmodifiableSet(replies);
+ public List<Reply> getReplies() {
+ List<Reply> sortedReplies = new ArrayList<Reply>(replies);
+ Collections.sort(sortedReplies, new Comparator<Reply>() {
+
+ @Override
+ public int compare(Reply leftReply, Reply rightReply) {
+ return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, leftReply.getTime() - rightReply.getTime()));
+ }
+
+ });
+ return sortedReplies;
}
/**
*/
@Override
public int hashCode() {
- return id.hashCode() ^ sone.hashCode() ^ (int) (time >>> 32) ^ (int) (time & 0xffffffff) ^ text.hashCode();
+ return id.hashCode() ^ sone.hashCode() ^ (int) (time >> 32) ^ (int) (time & 0xffffffff) ^ text.hashCode();
}
/**
return post.id.equals(id) && post.sone.equals(sone) && (post.time == time) && post.text.equals(text);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return getClass().getName() + "[id=" + getId() + ",sone=" + getSone() + ",time=" + getTime() + ",text=" + getText() + "]";
+ }
+
}