From: David ‘Bombe’ Roden Date: Wed, 17 Nov 2010 21:08:44 +0000 (+0100) Subject: Add method to not create a new post automatically. X-Git-Tag: 0.3-RC1~8 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=eaf58e65809b6edae309862f0d1da4ffeb32e626 Add method to not create a new post automatically. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 806ac21..ea491bb 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -495,9 +495,23 @@ public class Core implements IdentityListener { * @return The post, or {@code null} if there is no such post */ public Post getPost(String postId) { + return getPost(postId, true); + } + + /** + * Returns the post with the given ID, optionally creating a new post. + * + * @param postId + * The ID of the post to get + * @param create + * {@code true} it create a new post if no post with the given ID + * exists, {@code false} to return {@code null} + * @return The post, or {@code null} if there is no such post + */ + public Post getPost(String postId, boolean create) { synchronized (posts) { Post post = posts.get(postId); - if (post == null) { + if ((post == null) && create) { post = new Post(postId); posts.put(postId, post); }