From b30303b3e9af8e638daf07d2e0397b2ef5b301f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 22 Jan 2013 07:57:29 +0100 Subject: [PATCH] Fix checks for ID and time. --- src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java index d407133..967de9d 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java @@ -138,11 +138,9 @@ public class PostBuilderImpl implements PostBuilder { */ @Override public Post build() { - checkState(!randomId && (id == null), "neither random ID or custom ID set"); - checkState(randomId && (id != null), "both random ID and custom ID set"); + checkState((randomId && (id == null)) || (!randomId && (id != null)), "exactly one of random ID or custom ID must be set"); checkState(sender != null, "sender must not be null"); - checkState(!currentTime && (time == 0), "neither current time or custom time set"); - checkState(currentTime && (time != 0), "both current time and custom time set"); + checkState((currentTime && (time == 0)) || (!currentTime && (time > 0)), "one of current time or custom time must be set"); checkState(!StringUtils.isBlank(text), "text must not be empty"); checkState((recipient == null) || !recipient.equals(sender), "sender and recipient must not be the same"); return new PostImpl(randomId ? UUID.randomUUID().toString() : id, sender, currentTime ? System.currentTimeMillis() : time, text).setRecipient(recipient); -- 2.7.4