From: David ‘Bombe’ Roden Date: Thu, 24 Oct 2013 20:58:12 +0000 (+0200) Subject: Throw the correct exception when a duplicate field is added. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=aec69f3e199028a3dd6a71681f4ecc8fac1aa627;p=Sone.git Throw the correct exception when a duplicate field is added. --- diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index 5198f09..61cf291 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -22,7 +22,6 @@ import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Optional.of; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.UUID.randomUUID; @@ -155,7 +154,7 @@ public class Profile implements Fingerprintable { public Field addField(String fieldName) throws IllegalArgumentException { checkNotNull(fieldName, "fieldName must not be null"); checkArgument(fieldName.length() > 0, "fieldName must not be empty"); - checkState(!getFieldByName(fieldName).isPresent(), "fieldName must be unique"); + checkArgument(!getFieldByName(fieldName).isPresent(), "fieldName must be unique"); @SuppressWarnings("synthetic-access") Field field = new Field(fieldName); fields.add(field);