import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.SoneProvider;
/**
* Abstract base class for all replies.
*/
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
/** The ID of the reply. */
private final String id;
/** The Sone that created this reply. */
- private final Sone sone;
+ private final String soneId;
/** The time of the reply. */
private final long time;
/**
* Creates a new reply.
*
+ * @param soneProvider
+ * The Sone provider
* @param id
* The ID of the reply
- * @param sone
- * The Sone of the reply
+ * @param soneId
+ * The ID of the Sone of the reply
* @param time
* The time of the reply
* @param text
* The text of the reply
*/
- protected ReplyImpl(String id, Sone sone, long time, String text) {
+ protected ReplyImpl(SoneProvider soneProvider, String id, String soneId, long time, String text) {
+ this.soneProvider = soneProvider;
this.id = id;
- this.sone = sone;
+ this.soneId = soneId;
this.time = time;
this.text = text;
}
*/
@Override
public Sone getSone() {
- return sone;
+ return soneProvider.getSone(soneId).get();
}
/**
*/
@Override
public String toString() {
- return getClass().getName() + "[id=" + id + ",sone=" + sone + ",time=" + time + ",text=" + text + "]";
+ return String.format("%s[id=%s,sone=%s,time=%d,text=%s]", getClass().getName(), id, soneId, time, text);
}
}