projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Store all albums and images in the database after loading them from the configuration.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
data
/
impl
/
PostImpl.java
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java
b/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java
index
43d7d79
..
2d25715
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java
@@
-21,6
+21,9
@@
import java.util.UUID;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.SoneProvider;
+
+import com.google.common.base.Optional;
/**
* A post is a short message that a user writes in his Sone to let other users
/**
* A post is a short message that a user writes in his Sone to let other users
@@
-30,14
+33,17
@@
import net.pterodactylus.sone.data.Sone;
*/
public class PostImpl implements Post {
*/
public class PostImpl implements Post {
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
/** The GUID of the post. */
private final UUID id;
/** The GUID of the post. */
private final UUID id;
- /** The
Sone this post belongs to
. */
- private final S
one sone
;
+ /** The
ID of the owning Sone
. */
+ private final S
tring soneId
;
- /** The
Sone of the recipient
. */
- private final S
one recipient
;
+ /** The
ID of the recipient Sone
. */
+ private final S
tring recipientId
;
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
private final long time;
/** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
private final long time;
@@
-51,21
+57,24
@@
public class PostImpl implements Post {
/**
* Creates a new post.
*
/**
* Creates a new post.
*
+ * @param soneProvider
+ * The Sone provider
* @param id
* The ID of the post
* @param id
* The ID of the post
- * @param sone
- * The Sone this post belongs to
- * @param recipient
- * The recipient of the post
+ * @param sone
Id
+ * The
ID of the
Sone this post belongs to
+ * @param recipient
Id
+ * The
ID of the
recipient of the post
* @param time
* The time of the post (in milliseconds since Jan 1, 1970 UTC)
* @param text
* The text of the post
*/
* @param time
* The time of the post (in milliseconds since Jan 1, 1970 UTC)
* @param text
* The text of the post
*/
- public PostImpl(String id, Sone sone, Sone recipient, long time, String text) {
+ public PostImpl(SoneProvider soneProvider, String id, String soneId, String recipientId, long time, String text) {
+ this.soneProvider = soneProvider;
this.id = UUID.fromString(id);
this.id = UUID.fromString(id);
- this.sone
= sone
;
- this.recipient
= recipient
;
+ this.sone
Id = soneId
;
+ this.recipient
Id = recipientId
;
this.time = time;
this.text = text;
}
this.time = time;
this.text = text;
}
@@
-87,15
+96,23
@@
public class PostImpl implements Post {
*/
@Override
public Sone getSone() {
*/
@Override
public Sone getSone() {
- return sone;
+ return soneProvider.getSone(soneId).get();
+ }
+
+ /**
+ * {@inheritDocs}
+ */
+ @Override
+ public Optional<String> getRecipientId() {
+ return Optional.fromNullable(recipientId);
}
/**
* {@inheritDoc}
*/
@Override
}
/**
* {@inheritDoc}
*/
@Override
- public
Sone
getRecipient() {
- return
recipient
;
+ public
Optional<Sone>
getRecipient() {
+ return
soneProvider.getSone(recipientId)
;
}
/**
}
/**
@@
-160,7
+177,7
@@
public class PostImpl implements Post {
*/
@Override
public String toString() {
*/
@Override
public String toString() {
- return
getClass().getName() + "[id=" + id + ",sone=" + sone + ",time=" + time + ",text=" + text + "]"
;
+ return
String.format("%s[id=%s,sone=%s,recipient=%s,time=%d,text=%s]", getClass().getName(), id, soneId, recipientId, time, text)
;
}
}
}
}