Class ImmutableTriple<L,M,R>

java.lang.Object
org.aoju.bus.core.lang.tuple.Triple<L,M,R>
org.aoju.bus.core.lang.tuple.ImmutableTriple<L,M,R>
Type Parameters:
L - the left element type
M - the middle element type
R - the right element type
All Implemented Interfaces:
Serializable, Comparable<Triple<L,M,R>>

public final class ImmutableTriple<L,M,R> extends Triple<L,M,R>

An immutable triple consisting of three Object elements.

Although the implementation is immutable, there is no restriction on the objects that may be stored. If mutable objects are stored in the triple, then the triple itself effectively becomes mutable. The class is also final, so a subclass can not add undesirable behaviour.

#ThreadSafe# if all three objects are thread-safe

Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Field Details

    • left

      public final L left
      Left object
    • middle

      public final M middle
      Middle object
  • Constructor Details

    • ImmutableTriple

      public ImmutableTriple(L left, M middle, R right)
      Create a new triple instance.
      Parameters:
      left - the left value, may be null
      middle - the middle value, may be null
      right - the right value, may be null
  • Method Details

    • nullTriple

      public static <L, M, R> ImmutableTriple<L,M,R> nullTriple()
      Returns an immutable triple of nulls.
      Type Parameters:
      L - the left element of this triple. Value is null.
      M - the middle element of this triple. Value is null.
      R - the right element of this triple. Value is null.
      Returns:
      an immutable triple of nulls.
    • of

      public static <L, M, R> ImmutableTriple<L,M,R> of(L left, M middle, R right)

      Obtains an immutable triple of three objects inferring the generic types.

      This factory allows the triple to be created using inference to obtain the generic types.

      Type Parameters:
      L - the left element type
      M - the middle element type
      R - the right element type
      Parameters:
      left - the left element, may be null
      middle - the middle element, may be null
      right - the right element, may be null
      Returns:
      a triple formed from the three parameters, not null
    • getLeft

      public L getLeft()
      Specified by:
      getLeft in class Triple<L,M,R>
    • getMiddle

      public M getMiddle()
      Specified by:
      getMiddle in class Triple<L,M,R>
    • getRight

      public R getRight()
      Specified by:
      getRight in class Triple<L,M,R>