X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPost.java;h=24bcf8cb8001b4a41a9731240eee9e0ea6c4134f;hp=21ba42d353dc310a8c1fcde490d9bcf20c97b4d5;hb=a47643aed43d118ca68044f95451bb5374cdb332;hpb=96fcb6d250349cb1c02df44d6e3acdb93c8e7370 diff --git a/src/main/java/net/pterodactylus/sone/data/Post.java b/src/main/java/net/pterodactylus/sone/data/Post.java index 21ba42d..24bcf8c 100644 --- a/src/main/java/net/pterodactylus/sone/data/Post.java +++ b/src/main/java/net/pterodactylus/sone/data/Post.java @@ -1,5 +1,5 @@ /* - * FreenetSone - StatusUpdate.java - Copyright © 2010 David Roden + * Sone - Post.java - Copyright © 2010–2012 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 @@ -20,6 +20,8 @@ package net.pterodactylus.sone.data; import java.util.Comparator; import java.util.UUID; +import net.pterodactylus.util.filter.Filter; + /** * A post is a short message that a user writes in his Sone to let other users * know what is going on. @@ -38,6 +40,16 @@ public class Post { }; + /** Filter for posts with timestamps from the future. */ + public static final Filter FUTURE_POSTS_FILTER = new Filter() { + + @Override + public boolean filterObject(Post post) { + return post.getTime() <= System.currentTimeMillis(); + } + + }; + /** The GUID of the post. */ private final UUID id; @@ -53,6 +65,9 @@ public class Post { /** The text of the post. */ private volatile String text; + /** Whether the post is known. */ + private volatile boolean known; + /** * Creates a new post. * @@ -159,7 +174,9 @@ public class Post { * @return This post (for method chaining) */ public Post setRecipient(Sone recipient) { - this.recipient = recipient; + if (!sone.equals(recipient)) { + this.recipient = recipient; + } return this; } @@ -205,6 +222,27 @@ public class Post { return this; } + /** + * Returns whether this post is known. + * + * @return {@code true} if this post is known, {@code false} otherwise + */ + public boolean isKnown() { + return known; + } + + /** + * Sets whether this post is known. + * + * @param known + * {@code true} if this post is known, {@code false} otherwise + * @return This post + */ + public Post setKnown(boolean known) { + this.known = known; + return this; + } + // // OBJECT METHODS //