I expect two identical transforms to result objects that have the same hashCode. I'd like to use this property to check whether my object has changed in a meaningful way.
Unfortunately, Guava's TransformedCollection extends AbstractCollection which (unlike AbstractList) does not implement hashCode or equals, and TransformedCollection does no such attempt itself.
hashCode based on the values as returned by the iterator's order or some such? hashCodes? TransformedCollection in a way it cannot be solved for AbstractCollection?Unfortunately, there's no sane way for defining Collection.hashCode. A collection can be a Set or a List (or something else) and the two define hashCode in an incompatible way.
Moreover, for the same reason there's no sane definition for transformedCollection1.equals(transformedCollection2). It could either ignore the order, or not (Set or List semantics). Even worse, the returned Collection is just a view, and such equals would be terrible inefficient.
I'd suggest to use something like ImmutableList.copyOf(transformedCollection) and work with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With