de.caff.generics

## Class HashCacheWrapper<T>

- java.lang.Object
- - de.caff.generics.HashCacheWrapper<T>

-     public class HashCacheWrapper<T>
      extends java.lang.Object

  Helper class which is caching a hash value.

  Usage of this class is only making sense if the hash values of the underlying objects don't change, but that is true when depending on hashes anyway. Caching the hash is best if its calculation is expensive or the costs are unknown.

  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HashCacheWrapper(T wrapped)` Constructor.
    `HashCacheWrapper(T wrapped, HashCodeCalculator<? super T> hashCodeCalculator, UniformMatcher<? super T> matcher)` Constructor.
    `HashCacheWrapper(T wrapped, int hashCodeValue, UniformMatcher<? super T> matcher)` Constructor.
    `HashCacheWrapper(T wrapped, UniformMatcher<? super T> matcher)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object o)`
    `T` | `getWrapped()` Get the wrapped object.
    `int` | `hashCode()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HashCacheWrapper

          public HashCacheWrapper(T wrapped,
                                  int hashCodeValue,
                                  @Nullable
                                  UniformMatcher<? super T> matcher)

      Constructor.
      Parameters:
        `wrapped` - wrapped object
        `hashCodeValue` - hash value to use
        `matcher` - matcher to use for equality checks, if `null` `Match.DEFAULT_MATCHER` will be used

    - #### HashCacheWrapper

          public HashCacheWrapper(@NotNull
                                  T wrapped)

      Constructor. This will use the default hash value of the object and its equals method for equality checks.
      Parameters:
        `wrapped` - wrapped object

    - #### HashCacheWrapper

          public HashCacheWrapper(@NotNull
                                  T wrapped,
                                  @Nullable
                                  UniformMatcher<? super T> matcher)

      Constructor. This will use the default hash value of the object and its equals method for equality checks.
      Parameters:
        `wrapped` - wrapped object
        `matcher` - matcher used for equality checks

    - #### HashCacheWrapper

          public HashCacheWrapper(T wrapped,
                                  @NotNull
                                  HashCodeCalculator<? super T> hashCodeCalculator,
                                  @Nullable
                                  UniformMatcher<? super T> matcher)

      Constructor. This will use a dedicated hash code calculator and a dedicated matcher for equality checks.
      Parameters:
        `wrapped` - wrapped object
        `hashCodeCalculator` - hash code calculator
        `matcher` - matcher for equality checks, if `null` `Match.DEFAULT_MATCHER` will be used

  - ### Method Detail

    - #### getWrapped

          public T getWrapped()

      Get the wrapped object.
      Returns:
        wrapped object

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`