Skip to content

Commit e1bce22

Browse files
Use CollectionSizeException, fix comment
1 parent e03c984 commit e1bce22

File tree

1 file changed

+2
-5
lines changed
  • src/main/java/net/marcellperger/mathexpr/util

1 file changed

+2
-5
lines changed

src/main/java/net/marcellperger/mathexpr/util/Util.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ protected Util() {}
5959
@SuppressWarnings("UnusedReturnValue")
6060
@Contract("_ -> param1")
6161
public static <C extends Collection<?>> @NotNull C requireNonEmpty(@NotNull C collection) {
62-
// IllegalArgumentException might not always be appropriate
63-
if(collection.isEmpty()) throw new IllegalArgumentException("Argument must not be empty");
62+
if(collection.isEmpty()) throw new CollectionSizeException("Argument must not be empty");
6463
return collection;
6564
}
6665
@SuppressWarnings("UnusedReturnValue")
@@ -70,8 +69,7 @@ protected Util() {}
7069
}
7170
@Contract("_,_ -> param1")
7271
public static <C extends Collection<?>> @NotNull C requireNonEmpty(@NotNull C collection, String msg) {
73-
// IllegalArgumentException might not always be appropriate
74-
if(collection.isEmpty()) throw new IllegalArgumentException(msg);
72+
if(collection.isEmpty()) throw new CollectionSizeException(msg);
7573
return collection;
7674
}
7775
@SuppressWarnings("UnusedReturnValue")
@@ -81,7 +79,6 @@ protected Util() {}
8179
}
8280
@Contract("_,_ -> param1")
8381
public static <C extends Collection<?>> @NotNull C requireNonEmpty(@NotNull C collection, RuntimeException exc) {
84-
// IllegalArgumentException might not always be appropriate
8582
if(collection.isEmpty()) throw exc;
8683
return collection;
8784
}

0 commit comments

Comments
 (0)