/*
- * Sone - PostImpl.java - Copyright © 2010–2013 David Roden
+ * Sone - MemoryPost.java - Copyright © 2010–2019 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.database.memory;
+import static com.google.common.base.Optional.fromNullable;
+
import java.util.UUID;
import net.pterodactylus.sone.data.Post;
/**
* A post is a short message that a user writes in his Sone to let other users
* know what is going on.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
class MemoryPost implements Post {
/** The post database. */
- private final MemoryPostDatabase postDatabase;
+ private final MemoryDatabase postDatabase;
/** The Sone provider. */
private final SoneProvider soneProvider;
* @param text
* The text of the post
*/
- public MemoryPost(MemoryPostDatabase postDatabase, SoneProvider soneProvider, String id, String soneId, String recipientId, long time, String text) {
+ public MemoryPost(MemoryDatabase postDatabase, SoneProvider soneProvider, String id, String soneId, String recipientId, long time, String text) {
this.postDatabase = postDatabase;
this.soneProvider = soneProvider;
this.id = UUID.fromString(id);
return id.toString();
}
+ @Override
+ public boolean isLoaded() {
+ return true;
+ }
+
/**
* {@inheritDoc}
*/
@Override
public Sone getSone() {
- return soneProvider.getSone(soneId).get();
+ return soneProvider.getSone(soneId);
}
/**
*/
@Override
public Optional<String> getRecipientId() {
- return Optional.fromNullable(recipientId);
+ return fromNullable(recipientId);
}
/**
*/
@Override
public Optional<Sone> getRecipient() {
- return soneProvider.getSone(recipientId);
+ return recipientId == null ? Optional.<Sone>absent() : fromNullable(soneProvider.getSone(recipientId));
}
/**