diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/util/UserId.java b/pgpainless-core/src/main/java/org/pgpainless/key/util/UserId.java index 3ac3d77a..71ee8121 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/util/UserId.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/util/UserId.java @@ -22,20 +22,17 @@ public final class UserId implements CharSequence { this.email = email; } - public Builder withName(String name) { - checkNotNull("name", name); + public Builder withName(@Nonnull String name) { this.name = name; return this; } - public Builder withComment(String comment) { - checkNotNull("comment", comment); + public Builder withComment(@Nonnull String comment) { this.comment = comment; return this; } - public Builder withEmail(String email) { - checkNotNull("email", email); + public Builder withEmail(@Nonnull String email) { this.email = email; return this; } @@ -72,13 +69,10 @@ public final class UserId implements CharSequence { } public static UserId onlyEmail(@Nonnull String email) { - checkNotNull("email", email); return new UserId(null, null, email); } public static UserId nameAndEmail(@Nonnull String name, @Nonnull String email) { - checkNotNull("name", name); - checkNotNull("email", email); return new UserId(name, null, email); } @@ -180,10 +174,4 @@ public final class UserId implements CharSequence { || (!valueIsNull && !otherValueIsNull && (ignoreCase ? value.equalsIgnoreCase(otherValue) : value.equals(otherValue))); } - - private static void checkNotNull(String paramName, String value) { - if (value == null) { - throw new IllegalArgumentException(paramName + " must be not null"); - } - } } diff --git a/pgpainless-core/src/test/java/org/pgpainless/key/UserIdTest.java b/pgpainless-core/src/test/java/org/pgpainless/key/UserIdTest.java index 32d56eff..5fe4d9c9 100644 --- a/pgpainless-core/src/test/java/org/pgpainless/key/UserIdTest.java +++ b/pgpainless-core/src/test/java/org/pgpainless/key/UserIdTest.java @@ -10,25 +10,9 @@ import org.pgpainless.key.util.UserId; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; public class UserIdTest { - @Test - public void throwForNullName() { - assertThrows(IllegalArgumentException.class, () -> UserId.newBuilder().withName(null)); - } - - @Test - public void throwForNullComment() { - assertThrows(IllegalArgumentException.class, () -> UserId.newBuilder().withComment(null)); - } - - @Test - public void throwForNullEmail() { - assertThrows(IllegalArgumentException.class, () -> UserId.newBuilder().withEmail(null)); - } - @Test public void testFormatOnlyName() { assertEquals( @@ -66,11 +50,6 @@ public class UserIdTest { .toString()); } - @Test - public void throwIfOnlyEmailEmailNull() { - assertThrows(IllegalArgumentException.class, () -> UserId.onlyEmail(null)); - } - @Test public void testNameAndEmail() { UserId userId = UserId.nameAndEmail("Maurice Moss", "moss.m@reynholm.co.uk");