Class JavaHasher

java.lang.Object
org.pgcodekeeper.core.hasher.JavaHasher
All Implemented Interfaces:
Hasher

public class JavaHasher extends Object implements Hasher
Implementation of Hasher interface using Java's standard hash code computation. Uses prime number multiplication for combining hash values.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the current hash result.
    void
    put(boolean b)
    Adds a primitive boolean value to the hash computation
    void
    put(float f)
    Adds a primitive float value to the hash computation
    void
    put(int i)
    Adds a primitive int value to the hash computation
    void
    Adds a Boolean object to the hash computation
    void
    put(Enum<?> en)
    Adds an enum value to the hash computation
    void
    {Adds an Integer object to the hash computation
    void
    Adds a String value to the hash computation
    void
    put(List<String> col)
    Adds a List of Strings to the hash computation (order-sensitive)
    void
    Adds a Map of String key-value pairs to the hash computation
    void
    put(Set<String> col)
    Adds a Set of Strings to the hash computation (order-insensitive)
    void
    put(IHashable hashable)
    Adds a hashable object to the hash computation
    void
    Adds a Collection of hashable objects with order sensitivity
    void
    Adds a Collection of hashable objects with order insensitivity
    void
    putUnordered(Map<String,? extends IHashable> map)
    Adds an unordered Map of hashable objects to the hash computation.

    Methods inherited from class java.lang.Object

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

    • JavaHasher

      public JavaHasher()
  • Method Details

    • put

      public void put(boolean b)
      Description copied from interface: Hasher
      Adds a primitive boolean value to the hash computation
      Specified by:
      put in interface Hasher
    • put

      public void put(Boolean b)
      Adds a Boolean object to the hash computation
      Specified by:
      put in interface Hasher
      Parameters:
      b - the Boolean to hash (null-safe)
    • put

      public void put(String s)
      Adds a String value to the hash computation
      Specified by:
      put in interface Hasher
      Parameters:
      s - the String to hash (null-safe)
    • put

      public void put(int i)
      Description copied from interface: Hasher
      Adds a primitive int value to the hash computation
      Specified by:
      put in interface Hasher
    • put

      public void put(float f)
      Description copied from interface: Hasher
      Adds a primitive float value to the hash computation
      Specified by:
      put in interface Hasher
    • put

      public void put(Integer i)
      {Adds an Integer object to the hash computation}
      Specified by:
      put in interface Hasher
      Parameters:
      i - the Integer to hash (null-safe)
    • put

      public void put(IHashable hashable)
      Adds a hashable object to the hash computation
      Specified by:
      put in interface Hasher
      Parameters:
      hashable - the IHashable object to hash (null-safe)
    • put

      public void put(Enum<?> en)
      Adds an enum value to the hash computation
      Specified by:
      put in interface Hasher
      Parameters:
      en - the enum value to hash (null-safe)
    • put

      public void put(Map<String,String> map)
      Description copied from interface: Hasher
      Adds a Map of String key-value pairs to the hash computation
      Specified by:
      put in interface Hasher
    • put

      public void put(List<String> col)
      Description copied from interface: Hasher
      Adds a List of Strings to the hash computation (order-sensitive)
      Specified by:
      put in interface Hasher
    • put

      public void put(Set<String> col)
      Description copied from interface: Hasher
      Adds a Set of Strings to the hash computation (order-insensitive)
      Specified by:
      put in interface Hasher
    • putOrdered

      public void putOrdered(Collection<? extends IHashable> col)
      Description copied from interface: Hasher
      Adds a Collection of hashable objects with order sensitivity
      Specified by:
      putOrdered in interface Hasher
      Parameters:
      col - collection of objects implementing IHashable
    • putUnordered

      public void putUnordered(Collection<? extends IHashable> col)
      Description copied from interface: Hasher
      Adds a Collection of hashable objects with order insensitivity
      Specified by:
      putUnordered in interface Hasher
      Parameters:
      col - collection of objects implementing IHashable
    • getResult

      public int getResult()
      Gets the current hash result.
      Returns:
      the accumulated hash value
    • putUnordered

      public void putUnordered(Map<String,? extends IHashable> map)
      Adds an unordered Map of hashable objects to the hash computation.
      Specified by:
      putUnordered in interface Hasher
      Parameters:
      map - the map to hash (order-insensitive)