MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / apply

Method apply

java/src/org/openqa/selenium/json/EnumCoercer.java:32–52  ·  view source on GitHub ↗
(Type type)

Source from the content-addressed store, hash-verified

30 }
31
32 @Override
33 public BiFunction<JsonInput, PropertySetting, T> apply(Type type) {
34 Class<?> aClass = narrow(type);
35 if (!aClass.isEnum()) {
36 throw new JsonException("Type was not an enum: " + type);
37 }
38
39 return (jsonInput, setting) -> {
40 String value = jsonInput.nextString();
41
42 for (Object constant : aClass.getEnumConstants()) {
43 if (constant.toString().equalsIgnoreCase(value)) {
44 //noinspection unchecked
45 return (T) constant;
46 }
47 }
48
49 throw new JsonException(
50 String.format("Unable to find matching enum value for %s in %s", value, aClass));
51 };
52 }
53}

Callers

nothing calls this directly

Calls 4

nextStringMethod · 0.80
toStringMethod · 0.65
narrowMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected