de.caff.generics.tuple

## Class Tuple2<T1,T2>

- java.lang.Object
- - de.caff.generics.tuple.ITuple2.Base<T1,T2>
  - - de.caff.generics.tuple.Tuple2<T1,T2>

- Type Parameters:
    `T1` - type of first element
    `T2` - type of second element
  All Implemented Interfaces:
    ITuple2<T1,T2>, java.io.Serializable

      public class Tuple2<T1,T2>
      extends ITuple2.Base<T1,T2>
      implements java.io.Serializable

  Immutable tuple with 2 non-null elements. If you want to iterate over a tuple or access its elements by index (note that both is only possible for a common super type of the tuple's types) `Indexable.viewTuple(ITuple2)` will come to help. Note that this class is automatically created by `tools.TupleClassCreator` (not yet public).
  Since:
    November 17, 2021
  Author:
    Rammi
  See Also:
    `NTuple2`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface de.caff.generics.tuple.ITuple2

      `ITuple2.Base<T1,T2>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tuple2(T1 e1, T2 e2)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T1` | `_1()` Get the first element.
    `T2` | `_2()` Get the second element.
    `Tuple2<T2,T1>` | `_21()` Create a new 2-tuple from this one where the elements are ordered: 2nd, 1st.
    `Tuple2<T1,T2>` | `frozenNotNull()` Convert this into an object of a concrete tuple implementation.
    `<T> Tuple3<T,T1,T2>` | `i1(T e1)` Create a 3-tuple from this 2-tuple by inserting a new first element.
    `<T> Tuple3<T1,T,T2>` | `i2(T e2)` Create a 3-tuple from this 2-tuple by inserting a new second element.
    `<T> Tuple3<T1,T2,T>` | `i3(T e3)` Create a 3-tuple from this 2-tuple by adding a new third element.
    `java.lang.String` | `toString()`
    `<E1> Tuple2<E1,T2>` | `x1(E1 e1)` Create a 2-tuple from this one where the first element is exchanged.
    `<E2> Tuple2<T1,E2>` | `x2(E2 e2)` Create a 2-tuple from this one where the second element is exchanged.

    - ### Methods inherited from class de.caff.generics.tuple.ITuple2.Base

      `asBase, equals, hashCode`

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

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

    - ### Methods inherited from interface de.caff.generics.tuple.ITuple2

      `concat1, concat2, concat3, concat4, concat5, concat6, concat7, concat8, concatPred1, concatPred2, concatPred3, concatPred4, concatPred5, concatPred6, concatPred7, concatPred8, concatProc1, concatProc2, concatProc3, concatProc4, concatProc5, concatProc6, concatProc7, concatProc8, equals, frozen, hash, invoke, sendTo, testBy, toString, toString, view`

- - ### Constructor Detail

    - #### Tuple2

          public Tuple2(@NotNull
                        T1 e1,
                        @NotNull
                        T2 e2)

      Constructor.
      Parameters:
        `e1` - first element
        `e2` - second element

  - ### Method Detail

    - #### _1

          @NotNull
          public T1 _1()

      Description copied from interface: `ITuple2`
      Get the first element.
      Specified by:
        `_1` in interface `ITuple2<T1,T2>`
      Returns:
        first element

    - #### _2

          @NotNull
          public T2 _2()

      Description copied from interface: `ITuple2`
      Get the second element.
      Specified by:
        `_2` in interface `ITuple2<T1,T2>`
      Returns:
        second element

    - #### _21

          @NotNull
          public Tuple2<T2,T1> _21()

      Description copied from interface: `ITuple2`
      Create a new 2-tuple from this one where the elements are ordered: 2nd, 1st.
      Specified by:
        `_21` in interface `ITuple2<T1,T2>`
      Returns:
        reordered tuple

    - #### frozenNotNull

          @NotNull
          public Tuple2<T1,T2> frozenNotNull()

      Description copied from interface: `ITuple2`
      Convert this into an object of a concrete tuple implementation. This is useful because implementations may just be a view of something else. This method makes sure to decouple the tuple from the viewed object. The resulting tuple is guaranteed not to have `null` elements, but if this interface has `null` elements this method will throw a `NullPointerException`.

      See `ITuple2.frozen()` for a method which will not throw exceptions.

      Specified by:
        `frozenNotNull` in interface `ITuple2<T1,T2>`
      Returns:
        standalone tuple object

    - #### x1

          @NotNull
          public <E1> Tuple2<E1,T2> x1(@NotNull
                                                E1 e1)

      Create a 2-tuple from this one where the first element is exchanged.
      Type Parameters:
        `E1` - type of exchanged first element
      Parameters:
        `e1` - new first element
      Returns:
        tuple with exchanged element

    - #### x2

          @NotNull
          public <E2> Tuple2<T1,E2> x2(@NotNull
                                                E2 e2)

      Create a 2-tuple from this one where the second element is exchanged.
      Type Parameters:
        `E2` - type of exchanged second element
      Parameters:
        `e2` - new second element
      Returns:
        tuple with exchanged element

    - #### i1

          @NotNull
          public <T> Tuple3<T,T1,T2> i1(@NotNull
                                                 T e1)

      Create a 3-tuple from this 2-tuple by inserting a new first element.
      Type Parameters:
        `T` - new element type
      Parameters:
        `e1` - new element
      Returns:
        3-tuple

    - #### i2

          @NotNull
          public <T> Tuple3<T1,T,T2> i2(@NotNull
                                                 T e2)

      Create a 3-tuple from this 2-tuple by inserting a new second element.
      Type Parameters:
        `T` - new element type
      Parameters:
        `e2` - new element
      Returns:
        3-tuple

    - #### i3

          @NotNull
          public <T> Tuple3<T1,T2,T> i3(@NotNull
                                                 T e3)

      Create a 3-tuple from this 2-tuple by adding a new third element.
      Type Parameters:
        `T` - new element type
      Parameters:
        `e3` - new element
      Returns:
        3-tuple

    - #### toString

          @NotNull
          public java.lang.String toString()

      Overrides:
        `toString` in class `ITuple2.Base<T1,T2>`