Set<PostReply> storedReplies = storedSone.getReplies();
synchronized (knownReplies) {
for (PostReply reply : sone.getReplies()) {
- reply.setSone(storedSone).setKnown(knownReplies.contains(reply.getId()));
+ reply.setKnown(knownReplies.contains(reply.getId()));
if (!storedReplies.contains(reply)) {
if (reply.getTime() < getSoneFollowingTime(sone)) {
knownReplies.add(reply.getId());
*/
public Post getPost();
- /**
- * Sets the post this reply refers to.
- *
- * @param postId
- * The ID of the post to reply to
- * @return This reply
- */
- public PostReply setPost(String postId);
-
}
public Sone getSone();
/**
- * Sets the Sone that posted this reply.
- *
- * @param sone
- * The Sone that posted this reply
- * @return This reply
- */
- public T setSone(Sone sone);
-
- /**
* Returns the time of the reply.
*
* @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
public long getTime();
/**
- * Sets the time of the reply.
- *
- * @param time
- * The time of the reply (in milliseconds since Jan 1, 1970 UTC)
- * @return This reply
- */
- public T setTime(long time);
-
- /**
* Returns the text of the reply.
*
* @return The text of the reply
public String getText();
/**
- * Sets the text of the reply.
- *
- * @param text
- * The text of the reply
- * @return This reply
- */
- public T setText(String text);
-
- /**
* Returns whether this reply is known.
*
* @return {@code true} if this reply is known, {@code false} otherwise
checkState(postId != null, "post must not be null");
/* create new post reply. */
- PostReplyImpl postReplyImpl = new PostReplyImpl(postProvider, randomId ? UUID.randomUUID().toString() : id);
- postReplyImpl.setSone(sender);
- postReplyImpl.setPost(postId);
- postReplyImpl.setTime(currentTime ? System.currentTimeMillis() : time);
- postReplyImpl.setText(text);
- return postReplyImpl;
+ return new PostReplyImpl(postProvider, randomId ? UUID.randomUUID().toString() : id, sender, currentTime ? System.currentTimeMillis() : time, text, postId);
}
}
import net.pterodactylus.sone.core.PostProvider;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
+import net.pterodactylus.sone.data.Sone;
/**
* Simple {@link PostReply} implementation.
private final PostProvider postProvider;
/** The Post this reply refers to. */
- private volatile String postId;
+ private final String postId;
/**
* Creates a new reply.
* The post provider
* @param id
* The ID of the reply
+ * @param sone
+ * The Sone of the reply
+ * @param time
+ * The time of the reply
+ * @param text
+ * The text of the reply
+ * @param postId
+ * The ID of the post this reply refers to
*/
- public PostReplyImpl(PostProvider postProvider, String id) {
- super(id);
+ public PostReplyImpl(PostProvider postProvider, String id, Sone sone, long time, String text, String postId) {
+ super(id, sone, time, text);
this.postProvider = postProvider;
this.postId = postId;
}
return postProvider.getPost(postId);
}
- /**
- * Sets the post this reply refers to.
- *
- * @param postId
- * The ID of the post to reply to
- * @return This reply (for method chaining)
- */
- @Override
- public PostReply setPost(String postId) {
- this.postId = postId;
- return this;
- }
-
}
package net.pterodactylus.sone.data.impl;
-import java.util.UUID;
-
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
private final String id;
/** The Sone that created this reply. */
- private volatile Sone sone;
+ private final Sone sone;
/** The time of the reply. */
- private volatile long time;
+ private final long time;
/** The text of the reply. */
- private volatile String text;
+ private final String text;
/** Whether the reply is known. */
private volatile boolean known;
/**
- * Creates a new reply with the given ID.
- *
- * @param id
- * The ID of the reply
- */
- protected ReplyImpl(String id) {
- this(id, null, 0, null);
- }
-
- /**
- * Creates a new reply with a new random ID.
- *
- * @param sone
- * The Sone of the reply
- * @param time
- * The time of the reply
- * @param text
- * The text of the reply
- */
- protected ReplyImpl(Sone sone, long time, String text) {
- this(UUID.randomUUID().toString(), sone, time, text);
- }
-
- /**
* Creates a new reply.
*
* @param id
}
/**
- * Sets the Sone that posted this reply.
- *
- * @param sone
- * The Sone that posted this reply
- * @return This reply (for method chaining)
- */
- @Override
- @SuppressWarnings("unchecked")
- public T setSone(Sone sone) {
- this.sone = sone;
- return (T) this;
- }
-
- /**
* {@inheritDoc}
*/
@Override
}
/**
- * Sets the time of this reply.
- *
- * @param time
- * The time of this reply (in milliseconds since Jan 1, 1970 UTC)
- * @return This reply (for method chaining)
- */
- @Override
- @SuppressWarnings("unchecked")
- public T setTime(long time) {
- this.time = time;
- return (T) this;
- }
-
- /**
* {@inheritDoc}
*/
@Override
}
/**
- * Sets the text of this reply.
- *
- * @param text
- * The text of this reply
- * @return This reply (for method chaining)
- */
- @Override
- @SuppressWarnings("unchecked")
- public T setText(String text) {
- this.text = text;
- return (T) this;
- }
-
- /**
* {@inheritDoc}
*/
@Override