Guava's Range
only require one thing of its enclosed types: that they implement Comparable
.
But not all which implement Comparable
have a notion of distance. How would you measure the distance between two String
s, for instance?
This is why Guava also has DiscreteDomain
and ContiguousSet
; with the former you have methods such as next()
, prev()
and distance()
, which is what you are interested in here. Guava's site has an article on it.