Class HashUtil

java.lang.Object
org.cip4.jdflib.util.HashUtil

public class HashUtil extends Object
This class provides some hashCode calculation utilities. Use the static methods of this class to generate
 hashCode()
 
values in data objects. For example, to calculate the hashCode of a data object, use the methods of this class as follows:
 int myIntField;
 Object myObject;
 
 public int hashCode()
 {
        // int hash = super.hashCode(); // use when not extending Object
        int hash = 0; // use when extending Object
        hash = HashUtil.hashCode(hash, myIntField);
        hash = HashUtil.hashCode(hash, myObject);
        return hash;
 }
 

Hint: Start your hashCode calculation depending on the object your data object extends. If you extend Object initialize your hash value to 0. Otherwise initialize hash to super.hashCode(). See the example code.
  • Field Details

  • Method Details

    • hashCode

      public static final int hashCode(int source, boolean x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, int x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, long x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, float x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, double x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, Object x)
      Parameters:
      source -
      x -
      Returns:
    • hashCode

      public static final int hashCode(int source, Collection<?> c)
      Parameters:
      source -
      c -
      Returns:
    • hashCode

      public static final int hashCode(int source, Object[] x)
      Parameters:
      source -
      x -
      Returns: