de.caff.generics

## Class Subjectivity

- java.lang.Object
- - de.caff.generics.Subjectivity

-     public class Subjectivity
      extends java.lang.Object

  A subjective view on objects.

  This class allows to substitute objects with views which expose different `Object.equals(Object)` and `Object.hashCode()` implementations.

  It does not work on primitive types, but their boxed counterparts. If you provide a `Subjective` for a boxed primitive class it is also a good idea to provide one for its one-dimensional array type. E.g. if you provide a subjective for `Double` you should also provide one for `double[]`.

  Hashing of arrays is usually done flat, but you can change this by setting the `deep` flag in the constructors to `true`. This will influence all arrays, not just the ones which are handled by subjectives.

  Since:
    February 13, 2023
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Subjectivity(boolean deep, java.lang.Iterable<Subjective<?>> subjects)` Constructor.
    `Subjectivity(boolean deep, Subjective<?>... subjects)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `substitute(java.lang.Object obj)` Substitute the given object.
    `java.lang.Object` | `substitute0(java.lang.Object obj)` Substitute the given object which may be `null`.

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

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

- - ### Constructor Detail

    - #### Subjectivity

          public Subjectivity(boolean deep,
                              @NotNull
                              java.lang.Iterable<Subjective<?>> subjects)

      Constructor.
      Parameters:
        `deep` - make equals and hashcode work deep?
        `subjects` - subjective views used by this subjectivity

    - #### Subjectivity

          public Subjectivity(boolean deep,
                              @NotNull
                              Subjective<?>... subjects)

      Constructor.
      Parameters:
        `deep` - make equals and hashcode work deep?
        `subjects` - subjective views used by this subjectivity

  - ### Method Detail

    - #### substitute

          @NotNull
          public java.lang.Object substitute(@NotNull
                                                      java.lang.Object obj)

      Substitute the given object.

      It is strictly recommended to use a substitute only for checking equality or hashing.

      Parameters:
        `obj` - object to be substituted, not `null`
      Returns:
        `obj` if there is no substitution for the given object
        or a substitute which stands in for the object
      See Also:
        `substitute0(Object)`

    - #### substitute0

          @Nullable
          public java.lang.Object substitute0(@Nullable
                                                        java.lang.Object obj)

      Substitute the given object which may be `null`.
      Parameters:
        `obj` - object to be substituted, possibly `null`
      Returns:
        `obj` if there is no substitution for the given object, or it is `null`
        or a substitute which stands in for the object