Class HashCodeBuilder<T>

java.lang.Object
org.opendaylight.yangtools.util.HashCodeBuilder<T>
Type Parameters:
T - Component object type

public final class HashCodeBuilder<T> extends Object
Utility class for incrementally building object hashCode by hashing together component objects, one by one.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new instance, with internal hash initialized to 1, equivalent of HashCodeBuilder(1).
    HashCodeBuilder(int seedHash)
    Create a new instance, with internal hash set to specified seed.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Update the internal hash code with the hash code of a component object.
    int
    Return the currently-accumulated hash code.
    static int
    nextHashCode(int hashCode, Object obj)
    Determine the next hash code combining a base hash code and the hash code of an object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HashCodeBuilder

      public HashCodeBuilder()
      Create a new instance, with internal hash initialized to 1, equivalent of HashCodeBuilder(1).
    • HashCodeBuilder

      public HashCodeBuilder(int seedHash)
      Create a new instance, with internal hash set to specified seed.
      Parameters:
      seedHash - Seed hash value
  • Method Details

    • 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 code
      obj - 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 int build()
      Return the currently-accumulated hash code.
      Returns:
      Current hash code