From b2d188a64334a455dd6806ec89f0c85c9885d27d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Oct 2010 09:04:18 +0200 Subject: [PATCH] Add posts to Sone. --- .../java/net/pterodactylus/sone/data/Sone.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 -- 2.7.4