(Type type)
| 30 | } |
| 31 | |
| 32 | @Override |
| 33 | public BiFunction<JsonInput, PropertySetting, URL> apply(Type type) { |
| 34 | return (jsonInput, propertySetting) -> { |
| 35 | String toCoerce; |
| 36 | |
| 37 | switch (jsonInput.peek()) { |
| 38 | case NAME: |
| 39 | toCoerce = jsonInput.nextName(); |
| 40 | break; |
| 41 | |
| 42 | case STRING: |
| 43 | toCoerce = jsonInput.nextString(); |
| 44 | break; |
| 45 | |
| 46 | default: |
| 47 | throw new JsonException("Unable to coerce type to URL: " + jsonInput.peek()); |
| 48 | } |
| 49 | |
| 50 | try { |
| 51 | return new URL(toCoerce); |
| 52 | } catch (MalformedURLException e) { |
| 53 | throw new JsonException(e); |
| 54 | } |
| 55 | }; |
| 56 | } |
| 57 | } |
no test coverage detected