@Override
    public <T> Optional<T> valueAs(Class<T> type) {
        checkNotNull(type);

        if (type == Object.class || type == double.class || type == Double.class) {
            @SuppressWarnings("unchecked")
            T value = (T) Double.valueOf(this.value);
            return Optional.of(value);
        }

        return Optional.empty();
    }
@Test
    public void testValueAsObject() {
        ContinuousResource resource = Resources.continuous(D1, P1, Bandwidth.class)
                .resource(BW1.bps());

        Optional<Double> value = resource.valueAs(Double.class);
        assertThat(value.get(), is(BW1.bps()));
    }