class EncodedDiscreteResources {

    @SuppressWarnings("unchecked")
    boolean contains(DiscreteResource resource) {
        return resource.valueAs(Object.class)
                .map(x -> codec.encode(x))
                .map(rangeSet::contains)
                .orElse(false);
    }

      EncodedDiscreteResources(RangeSet<Integer> rangeSet, DiscreteResourceCodec codec);

}