From: David ‘Bombe’ Roden Date: Thu, 14 Oct 2010 07:04:18 +0000 (+0200) Subject: Add posts to Sone. X-Git-Tag: 0.1-RC1~429 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b2d188a64334a455dd6806ec89f0c85c9885d27d;p=Sone.git Add posts to Sone. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index b70dbdb..33b97a0 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -17,8 +17,10 @@ package net.pterodactylus.sone.data; +import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; @@ -53,6 +55,9 @@ public class Sone { /** All friend Sones. */ private final Set friendSones = new HashSet(); + /** All posts. */ + private final List posts = new ArrayList(); + /** Modification count. */ private volatile long modificationCounter = 0; @@ -203,6 +208,39 @@ public class Sone { } /** + * Returns the list of posts of this Sone. + * + * @return All posts of this Sone + */ + public List getPosts() { + return Collections.unmodifiableList(posts); + } + + /** + * Adds the given post to this Sone. + * + * @param post + * The post to add + */ + public synchronized void addPost(Post post) { + if (posts.add(post)) { + modificationCounter++; + } + } + + /** + * Removes the given post from this Sone. + * + * @param post + * The post to remove + */ + public synchronized void removePost(Post post) { + if (posts.remove(post)) { + modificationCounter++; + } + } + + /** * Returns the modification counter. * * @return The modification counter