Skip to content

Commit 3214588

Browse files
committed
Reports null checks were replaced with a call to a static method from Objects
1 parent 4b7d174 commit 3214588

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

java/src/org/openqa/selenium/internal/Require.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@ public static int positive(String argName, Integer number, String message) {
129129
throw new IllegalArgumentException(String.format(MUST_BE_SET, argName));
130130
}
131131
if (number <= 0) {
132-
if (message == null) {
133-
throw new IllegalArgumentException(String.format(MUST_BE_POSITIVE, argName));
134-
} else {
135-
throw new IllegalArgumentException(message);
136-
}
132+
throw new IllegalArgumentException(Objects.requireNonNullElseGet(message, () -> String.format(MUST_BE_POSITIVE, argName)));
137133
}
138134
return number;
139135
}
@@ -143,11 +139,7 @@ public static double positive(String argName, Double number, String message) {
143139
throw new IllegalArgumentException(String.format(MUST_BE_SET, argName));
144140
}
145141
if (number <= 0) {
146-
if (message == null) {
147-
throw new IllegalArgumentException(String.format(MUST_BE_POSITIVE, argName));
148-
} else {
149-
throw new IllegalArgumentException(message);
150-
}
142+
throw new IllegalArgumentException(Objects.requireNonNullElseGet(message, () -> String.format(MUST_BE_POSITIVE, argName)));
151143
}
152144
return number;
153145
}

0 commit comments

Comments
 (0)