import java.util.UUID;
-import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.Database;
+
+import com.google.common.base.Optional;
/**
* A post is a short message that a user writes in his Sone to let other users
*/
public class PostImpl implements Post {
- /** The Sone provider. */
- private final SoneProvider soneProvider;
+ private final Database database;
/** The GUID of the post. */
private final UUID id;
/**
* Creates a new post.
*
- * @param soneProvider
- * The Sone provider
+ * @param database
+ * The database
* @param id
* The ID of the post
* @param soneId
* @param text
* The text of the post
*/
- public PostImpl(SoneProvider soneProvider, String id, String soneId, String recipientId, long time, String text) {
- this.soneProvider = soneProvider;
+ public PostImpl(Database database, String id, String soneId, String recipientId, long time, String text) {
+ this.database = database;
this.id = UUID.fromString(id);
this.soneId = soneId;
this.recipientId = recipientId;
*/
@Override
public Sone getSone() {
- return soneProvider.getSone(soneId);
+ return database.getSone(soneId).get();
+ }
+
+ /**
+ * {@inheritDocs}
+ */
+ @Override
+ public Optional<String> getRecipientId() {
+ return Optional.fromNullable(recipientId);
}
/**
* {@inheritDoc}
*/
@Override
- public Sone getRecipient() {
- return soneProvider.getSone(recipientId);
+ public Optional<Sone> getRecipient() {
+ return database.getSone(recipientId);
}
/**