ProvidenceConfigUtil { static double asDouble(Object value) throws ProvidenceConfigException { if (value instanceof Number) { return ((Number) value).doubleValue(); } else if (value instanceof Numeric) { return ((Numeric) value).asInteger(); } throw new ProvidenceConfigException( "Unable to convert " + value.getClass().getSimpleName() + " to a double"); } private  ProvidenceConfigUtil(); static Path canonicalFileLocation(@Nonnull Path file); static final String UNDEFINED; }
@Test public void testAsDouble() throws ProvidenceConfigException { assertThat(asDouble(5.5f), is(5.5)); assertThat(asDouble((byte) 5), is(5.0)); assertThat(asDouble((Numeric) () -> 55), is(55.0)); try { asDouble("foo"); fail("no exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Unable to convert String to a double")); } try { asDouble(new Object()); fail("no exception"); } catch (ProvidenceConfigException e) { assertThat(e.getMessage(), is("Unable to convert Object to a double")); } }