public final class HashCode extends Object implements Scalar<Integer>
public int hashCode() {
int hash = 5;
hash = 67 * hash + Objects.hashCode(this.attr1);
hash = 67 * hash + Objects.hashCode(this.attr2);
hash = 67 * hash + Objects.hashCode(this.attr3);
// ... more attributes
return hash;
}
With this:
public int hashCode() {
return new HashCode(
5, 67,
this.attr1, this.attr2, this.attr3, ...
).value();
}
There is no thread-safety guarantee.
public HashCode(Object... attributes)
The initial
and multiplier
values are arbitrarily
set to 17 and 31 respectively.
attributes
- The object's attributespublic HashCode(Iterable<?> attributes)
The initial
and multiplier
values are arbitrarily
set to 17 and 31 respectively.
attributes
- The object's attributespublic HashCode(int initial, int multiplier, Object... attributes)
initial
- Initial value (non-zero recommended)multiplier
- Step multiplier (odd prime recommended)attributes
- The object's attributespublic HashCode(int initial, int multiplier, Iterable<?> attributes)
initial
- Initial value (non-zero recommended)multiplier
- Step multiplier (odd prime recommended)attributes
- The object's attributesCopyright © 2017–2021 Cactoos. All rights reserved.