I'm wondering if it's possible to use Guava Range to iterate on a list of custom objects.
I have this example, which should get an interval of 5 items in a list:
Range<CustomObject> range = Range.closed(customObjectList.get(Auxiliar.index), customObjectList.get(Auxiliar.index + 4));
And then I would like to iterate on this range to get my list of object, I mean, to be able to do something like that:
List<CustomObject> list = new ArrayList<CustomObject>();
for(CustomObject c : range){
list.add(c)
}
At the moment I can't do this foreach on a Guava Range, instead I have to do that like here:
for(int grade : ContiguousSet.create(yourRange, DiscreteDomain.integers())) {
...
}
But here the problem is, I can't use DiscreteDomain.CustomObject().
Is there a way to use this Guava Range with a list of CustomObject ?