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

        return id.lastComponentAs(type);
    }
@Test
    public void testValueAs() {
        DiscreteResource resource = Resources.discrete(D1).resource();

        Optional<DeviceId> volume = resource.valueAs(DeviceId.class);
        assertThat(volume.get(), is(D1));
    }