Package org.opendaylight.yangtools.util
Class HashCodeBuilder<T>
- java.lang.Object
-
- org.opendaylight.yangtools.util.HashCodeBuilder<T>
-
- Type Parameters:
T
- Component object type
- All Implemented Interfaces:
Builder<Integer>
,CheckedBuilder<Integer,IllegalArgumentException>
,Mutable
,MutationBehaviour<Mutable>
public final class HashCodeBuilder<T> extends Object implements Builder<Integer>
Utility class for incrementally building object hashCode by hashing together component objects, one by one.
-
-
Constructor Summary
Constructors Constructor Description HashCodeBuilder()
Create a new instance, with internal hash initialized to 1, equivalent ofHashCodeBuilder(1)
.HashCodeBuilder(int seedHash)
Create a new instance, with internal hash set to specified seed.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArgument(T obj)
Update the internal hash code with the hash code of a component object.@NonNull Integer
build()
Returns instance of the product.static int
nextHashCode(int hashCode, Object obj)
Determine the next hash code combining a base hash code and the hash code of an object.
-
-
-
Constructor Detail
-
HashCodeBuilder
public HashCodeBuilder()
Create a new instance, with internal hash initialized to 1, equivalent ofHashCodeBuilder(1)
.
-
HashCodeBuilder
public HashCodeBuilder(int seedHash)
Create a new instance, with internal hash set to specified seed.- Parameters:
seedHash
- Seed hash value
-
-
Method Detail
-
nextHashCode
public static int nextHashCode(int hashCode, Object obj)
Determine the next hash code combining a base hash code and the hash code of an object.- Parameters:
hashCode
- base hash codeobj
- Object to be added- Returns:
- Combined hash code
-
addArgument
public void addArgument(T obj)
Update the internal hash code with the hash code of a component object.- Parameters:
obj
- Component object
-
build
public @NonNull Integer build()
Description copied from interface:CheckedBuilder
Returns instance of the product. Multiple calls to this method are not required to return same instance if the state of the builder has changed.- Specified by:
build
in interfaceBuilder<T>
- Specified by:
build
in interfaceCheckedBuilder<Integer,IllegalArgumentException>
- Returns:
- A newly-built instance
-
-