Remove @author tags
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / ReplyImpl.java
index 46f49dd..3d6d6fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - ReplyImpl.java - Copyright © 2011–2012 David Roden
+ * Sone - ReplyImpl.java - Copyright © 2011–2016 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
 
 package net.pterodactylus.sone.data.impl;
 
-import java.util.UUID;
-
 import net.pterodactylus.sone.data.Reply;
 import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.SoneProvider;
 
 /**
  * Abstract base class for all replies.
  *
  * @param <T>
  *            The type of the reply
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 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 volatile Sone sone;
+       private final String soneId;
 
        /** 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 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;
        }
@@ -102,21 +82,7 @@ public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
         */
        @Override
        public Sone getSone() {
-               return sone;
-       }
-
-       /**
-        * 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;
+               return soneProvider.getSone(soneId);
        }
 
        /**
@@ -128,20 +94,6 @@ public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
        }
 
        /**
-        * 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
@@ -150,20 +102,6 @@ public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
        }
 
        /**
-        * 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
@@ -210,7 +148,7 @@ public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
         */
        @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);
        }
 
 }