(Type type)
| 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 | } |
nothing calls this directly
no test coverage detected