cactoos
cactoos copied to clipboard
All concrete classes implementing Scalar/Func/BiFunc should override equals and hashCode
To make classes like IoCheckedScalar more useful we should implement equals and hashCode methods in them.
Currently one has to use value() to get the underlying object and call equals/hashCode there, it shouldn't be required.
@llorllale/z please, pay attention to this issue
@krzyk if we do that, then we may trigger any side effects or use up resources excessively. There may be a scenario where a resource is available only once, after which successive invocations may fail or produce a different output.
Make sense?
@llorllale But that will be up to the user if he will use those methods, without those one can't use e.g. Scalars as map keys or using any find method.
So maybe create another class that will implement Scalar/Function/BiFunction that will override equals/hashcode.
@krzyk I can't think of a name for this new class
@llorllale maybe Keyable (because it can be used as a key in map), or Hashable?
@krzyk I strongly believe that equals() is independent of hashcode(), although not the other way around, and I think they should be separate interfaces.
Looking through what we currently have:
- Scalar
Equalslooks ok, I'm just thinking the "s" should be dropped from the name. - Scalar
Equalitymakes no sense to me. I think it should be scrapped.
I think we would need a new Equals class of type Scalar<Boolean> that would decorate other scalars and implement Object.equals(). A warning should be present saying that if the resource is expensive then users should decorate the target scalar with StickyScalar.
WDYT?