From f6790f16a4d666b2485429a5ce707885ad059c33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Nov 2010 13:48:29 +0100 Subject: [PATCH] Add method to optionally skip reply creation. --- .../java/net/pterodactylus/sone/core/Core.java | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 90443ce..54908d8 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -572,16 +572,33 @@ public class Core implements IdentityListener { } /** - * Returns the reply with the given ID. + * Returns the reply with the given ID. If there is no reply with the given + * ID yet, a new one is created. * * @param replyId * The ID of the reply to get - * @return The reply, or {@code null} if there is no such reply + * @return The reply */ public Reply getReply(String replyId) { + return getReply(replyId, true); + } + + /** + * Returns the reply with the given ID. If there is no reply with the given + * ID yet, a new one is created, unless {@code create} is false in which + * case {@code null} is returned. + * + * @param replyId + * The ID of the reply to get + * @param create + * {@code true} to always return a {@link Reply}, {@code false} + * to return {@code null} if no reply can be found + * @return The reply, or {@code null} if there is no such reply + */ + public Reply getReply(String replyId, boolean create) { synchronized (replies) { Reply reply = replies.get(replyId); - if (reply == null) { + if (create && (reply == null)) { reply = new Reply(replyId); replies.put(replyId, reply); } -- 2.7.4