JsonConverter extends AbstractConfigurationConverter { Number readNumberFromValue(final String key, final @Nullable Object value) throws ComponentConfigurationException { if (value instanceof Number) { return (Number) value; } else if (value instanceof String) { Object readValue = stringToValue((String) value); if (readValue instanceof Number) { return (Number) readValue; } else if (!isBlankish(readValue)) { throw new ComponentConfigurationException("Failed to parse value for key " + key + " as number."); } } return null; }  static String plexusPluralStem(final String key); @Override boolean canConvert(final Class<?> type); @Override Object fromConfiguration(final ConverterLookup lookup,
                                    final PlexusConfiguration configuration,
                                    final Class<?> type,
                                    final Class<?> enclosingType,
                                    final ClassLoader loader,
                                    final ExpressionEvaluator evaluator,
                                    final ConfigurationListener listener); JsonValue convertChild(final @NotNull PlexusConfiguration child, final ExpressionEvaluator evaluator); static Object stringToValue(String string);  }
@Test public void testReadNumberFromValue() throws Exception { Number[] numbers = Stream.of(1, 2.0, ((long) Integer.MAX_VALUE) + 4, ((Float) Float.MAX_VALUE).doubleValue() + 1.0D) .toArray(Number[]::new); for (Number number : numbers) { assertSame("same number", number, converter().readNumberFromValue("", number)); assertEquals("toString equals", number, converter().readNumberFromValue("", number.toString())); } assertNull("should be null", converter().readNumberFromValue("", Boolean.TRUE)); }
@Test(expected = ComponentConfigurationException.class) public void testReadNumberFromValue_nonNumericString() throws Exception { converter().readNumberFromValue("", "foo"); }