Skip to content

Commit f7712a4

Browse files
committed
added value check
1 parent 9ed2923 commit f7712a4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/com/eliasnogueira/enums/Target.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
public enum Target {
3535

36-
LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"), TESTCONTAINERS("testcontainers");
36+
LOCAL("local"), LOCAL_SUITE("local-suite"), SELENIUM_GRID("selenium-grid"),
37+
TESTCONTAINERS("testcontainers");
3738

3839
private final String value;
3940
private static final Map<String, Target> ENUM_MAP;
@@ -43,12 +44,15 @@ public enum Target {
4344
}
4445

4546
static {
46-
Map<String, Target> map = stream(Target.values()).collect(toMap(
47-
instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new));
47+
Map<String, Target> map = stream(Target.values())
48+
.collect(toMap(instance -> instance.value.toLowerCase(), instance -> instance, (a, b) -> b, ConcurrentHashMap::new));
4849
ENUM_MAP = Collections.unmodifiableMap(map);
4950
}
5051

5152
public static Target get(String value) {
53+
if (!ENUM_MAP.containsKey(value.toLowerCase()))
54+
throw new IllegalArgumentException(String.format("Value %s not valid. Use one of the TARGET enum values", value));
55+
5256
return ENUM_MAP.get(value.toLowerCase());
5357
}
5458
}

0 commit comments

Comments
 (0)