import static com.google.common.collect.FluentIterable.from;
import java.util.List;
-import java.util.UUID;
+import java.util.Set;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
private final Database database;
- /** The GUID of the post. */
- private final UUID id;
+ /** The ID of the post. */
+ private final String id;
/** The ID of the owning Sone. */
private final String soneId;
/** The text of the post. */
private final String text;
- /** Whether the post is known. */
- private volatile boolean known;
-
/**
* Creates a new post.
*
*/
public DefaultPost(Database database, String id, String soneId, String recipientId, long time, String text) {
this.database = database;
- this.id = UUID.fromString(id);
+ this.id = id;
this.soneId = soneId;
this.recipientId = recipientId;
this.time = time;
@Override
public String getId() {
- return id.toString();
+ return id;
}
@Override
@Override
public boolean isKnown() {
- return known;
+ return database.isPostKnown(this);
}
@Override
- public DefaultPost setKnown(boolean known) {
- this.known = known;
+ public DefaultPost setKnown() {
+ database.setPostKnown(this);
return this;
}
@Override
+ public void like(Sone localSone) {
+ database.likePost(this, localSone);
+ }
+
+ @Override
+ public void unlike(Sone localSone) {
+ database.unlikePost(this, localSone);
+ }
+
+ @Override
+ public boolean isLiked(Sone sone) {
+ return database.isLiked(this, sone);
+ }
+
+ @Override
+ public Set<Sone> getLikes() {
+ return database.getLikes(this);
+ }
+
+ @Override
public List<PostReply> getReplies() {
return from(database.getReplies(getId())).toSortedList(Reply.TIME_COMPARATOR);
}