Throw the correct exception when a duplicate field is added.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 24 Oct 2013 20:58:12 +0000 (22:58 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:36 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/data/Profile.java

index 5198f09..61cf291 100644 (file)
@@ -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);