Guava can support this if you compose two operations together. First, you create the set {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Then, you filter it.
To turn the Range
into the intermediate, unfiltered set, create a ContiguousSet
. To do so, you'll need a DiscreteDomain
, which is basically the SomeFunctionInterface
you've described. Since you're dealing with integers, you can use the built-in DiscreteDomain.integers()
.
To get from there to the set of only even numbers, you can write a Predicate
and then pass it and the intermediate set to Sets.filter
.