X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FReplyImpl.java;h=b3681d7fdf467cc241966c6525fbb217cb28254e;hb=2ef163831826acdb2113f04278d90fa0a60d3f8e;hp=ee8c01e8afdd59cf12b072fed0248b093d75bf23;hpb=83ceb7c20927ae3cd9eb12d8d885462ac66ea6a4;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java index ee8c01e..b3681d7 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java @@ -17,8 +17,10 @@ package net.pterodactylus.sone.data.impl; +import net.pterodactylus.sone.data.IdBuilder; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.SoneProvider; /** * Abstract base class for all replies. @@ -29,11 +31,16 @@ import net.pterodactylus.sone.data.Sone; */ public abstract class ReplyImpl> implements Reply { + private final IdBuilder idBuilder = new IdBuilder(); + + /** 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; @@ -47,18 +54,21 @@ public abstract class ReplyImpl> implements Reply { /** * 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; } @@ -68,6 +78,11 @@ public abstract class ReplyImpl> implements Reply { */ @Override public String getId() { + return idBuilder.buildId(soneId, id); + } + + @Override + public String getInternalId() { return id; } @@ -76,7 +91,7 @@ public abstract class ReplyImpl> implements Reply { */ @Override public Sone getSone() { - return sone; + return soneProvider.getSone(soneId).get(); } /** @@ -142,7 +157,7 @@ public abstract class ReplyImpl> implements Reply { */ @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); } }