@SuppressWarnings("unchecked")
    boolean contains(DiscreteResource resource) {
        return resource.valueAs(Object.class)
                .map(x -> codec.encode(x))
                .map(rangeSet::contains)
                .orElse(false);
    }
@Test
    public void testContains() {
        DiscreteResource res1 = Resources.discrete(DID, PN, VID1).resource();
        DiscreteResource res2 = Resources.discrete(DID, PN, VID2).resource();
        DiscreteResource res3 = Resources.discrete(DID, PN, VID3).resource();

        Set<DiscreteResource> resources = ImmutableSet.of(res1, res2);

        EncodedDiscreteResources sut = EncodedDiscreteResources.of(resources, new VlanIdCodec());

        assertThat(sut.contains(res1), is(true));
        assertThat(sut.contains(res3), is(false));
    }