public static class Objects.HashCodeBuilder
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
HashCodeBuilder(int seed)
Private constructor for builder pattern.
|
Modifier and Type | Method and Description |
---|---|
Objects.HashCodeBuilder |
add(boolean b)
Adds the hash code of a boolean to the final hash code value.
|
Objects.HashCodeBuilder |
add(char c)
Adds the hash code of a character to the final hash code value.
|
Objects.HashCodeBuilder |
add(double dbl)
Adds the hash code of a double to the final hash code value.
|
Objects.HashCodeBuilder |
add(float flt)
Adds the hash code of a float to the final hash code value.
|
Objects.HashCodeBuilder |
add(int i)
Adds the hash code of an integer to the final hash code value.
|
Objects.HashCodeBuilder |
add(long lng)
Adds the hash code of a long to the final hash code value.
|
Objects.HashCodeBuilder |
add(java.lang.Object obj)
Adds the hash code of an object to the final hash code value.
|
static Objects.HashCodeBuilder |
builder()
Creates a new builder with 31 as the seed.
|
static Objects.HashCodeBuilder |
builder(int seed)
Creates a new builder with the seed that is passed.
|
private int |
calc()
Calculates the default.
|
boolean |
equals(java.lang.Object obj)
Should never be invoked on this object.
|
int |
hashCode()
This method overrides the default
Object#hashCode() , but does
not return a proper hash of this builder. |
int |
toHashCode()
Returns the calculated hash code.
|
private HashCodeBuilder(int seed)
seed
- the seed for the hash code.public static Objects.HashCodeBuilder builder()
public static Objects.HashCodeBuilder builder(int seed)
seed
- the seed for the hash code.public Objects.HashCodeBuilder add(boolean b)
b
- a boolean to calculate the hash code of.public Objects.HashCodeBuilder add(char c)
c
- a character to calculate the hash code of.public Objects.HashCodeBuilder add(int i)
Both shorts and bytes use this method to add the hash value.
i
- an integer to calculate the hash code of.public Objects.HashCodeBuilder add(long lng)
lng
- a long to calculate the hash code of.public Objects.HashCodeBuilder add(float flt)
flt
- a float to calculate the hash code of.public Objects.HashCodeBuilder add(double dbl)
dbl
- a double to calculate the hash code of.public Objects.HashCodeBuilder add(java.lang.Object obj)
If the obj
is null
the hash code is calculated using
add(int)
with a value of 0. Otherwise the hash code is
calculated using add(int)
with a value of
obj.hashCode()
, unless the object is an array. In this case
the array is processed and this is recursively invoked.
obj
- the object to calculate the hash code of.public int toHashCode()
public int hashCode()
Object#hashCode()
, but does
not return a proper hash of this builder. Returns the value of
toHashCode()
to insure the incorrect hash code is not returned
by mistake.hashCode
in class java.lang.Object
toHashCode()
.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- an object.private int calc()