Package org.jboss.logging.processor.util
Class Objects.HashCodeBuilder
- java.lang.Object
-
- org.jboss.logging.processor.util.Objects.HashCodeBuilder
-
- Enclosing class:
- Objects
public static class Objects.HashCodeBuilder extends java.lang.ObjectA builder to simplify the building of hash codes.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objects.HashCodeBuilderadd(boolean b)Adds the hash code of a boolean to the final hash code value.Objects.HashCodeBuilderadd(char c)Adds the hash code of a character to the final hash code value.Objects.HashCodeBuilderadd(double dbl)Adds the hash code of a double to the final hash code value.Objects.HashCodeBuilderadd(float flt)Adds the hash code of a float to the final hash code value.Objects.HashCodeBuilderadd(int i)Adds the hash code of an integer to the final hash code value.Objects.HashCodeBuilderadd(long lng)Adds the hash code of a long to the final hash code value.Objects.HashCodeBuilderadd(java.lang.Object obj)Adds the hash code of an object to the final hash code value.static Objects.HashCodeBuilderbuilder()Creates a new builder with 31 as the seed.static Objects.HashCodeBuilderbuilder(int seed)Creates a new builder with the seed that is passed.booleanequals(java.lang.Object obj)Should never be invoked on this object.inthashCode()This method overrides the defaultObject#hashCode(), but does not return a proper hash of this builder.inttoHashCode()Returns the calculated hash code.
-
-
-
Method Detail
-
builder
public static Objects.HashCodeBuilder builder()
Creates a new builder with 31 as the seed.- Returns:
- the new builder.
-
builder
public static Objects.HashCodeBuilder builder(int seed)
Creates a new builder with the seed that is passed.- Parameters:
seed- the seed for the hash code.- Returns:
- the new builder.
-
add
public Objects.HashCodeBuilder add(boolean b)
Adds the hash code of a boolean to the final hash code value.- Parameters:
b- a boolean to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(char c)
Adds the hash code of a character to the final hash code value.- Parameters:
c- a character to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(int i)
Adds the hash code of an integer to the final hash code value.Both shorts and bytes use this method to add the hash value.
- Parameters:
i- an integer to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(long lng)
Adds the hash code of a long to the final hash code value.- Parameters:
lng- a long to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(float flt)
Adds the hash code of a float to the final hash code value.- Parameters:
flt- a float to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(double dbl)
Adds the hash code of a double to the final hash code value.- Parameters:
dbl- a double to calculate the hash code of.- Returns:
- the current builder.
-
add
public Objects.HashCodeBuilder add(java.lang.Object obj)
Adds the hash code of an object to the final hash code value.If the
objisnullthe hash code is calculated usingadd(int)with a value of 0. Otherwise the hash code is calculated usingadd(int)with a value ofobj.hashCode(), unless the object is an array. In this case the array is processed and this is recursively invoked.- Parameters:
obj- the object to calculate the hash code of.- Returns:
- the current builder.
-
toHashCode
public int toHashCode()
Returns the calculated hash code.- Returns:
- the calculated hash code.
-
hashCode
public int hashCode()
This method overrides the defaultObject#hashCode(), but does not return a proper hash of this builder. Returns the value oftoHashCode()to insure the incorrect hash code is not returned by mistake.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the value of
toHashCode().
-
equals
public boolean equals(java.lang.Object obj)
Should never be invoked on this object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- an object.
-
-