Class Triple<A,​B,​C>

  • Type Parameters:
    A - the first element type
    B - the second element type
    C - the third element type
    All Implemented Interfaces:
    Tuple, java.io.Serializable, java.lang.Comparable<Triple<A,​B,​C>>, Bean, ImmutableBean

    public final class Triple<A,​B,​C>
    extends java.lang.Object
    implements ImmutableBean, Tuple, java.lang.Comparable<Triple<A,​B,​C>>, java.io.Serializable
    An immutable triple consisting of three elements.

    This implementation refers to the elements as 'first', 'second' and 'third'. The elements cannot be null.

    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.

    This class is immutable and thread-safe if the stored objects are immutable.

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Triple.Meta<A,​B,​C>
      The meta-bean for Triple.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Triple<A,​B,​C> other)
      Compares the triple based on the first element followed by the second element followed by the third element.
      com.google.common.collect.ImmutableList<java.lang.Object> elements()
      Gets the elements from this triple as a list.
      boolean equals​(java.lang.Object obj)  
      A getFirst()
      Gets the first element in this pair.
      B getSecond()
      Gets the second element in this pair.
      C getThird()
      Gets the third element in this pair.
      int hashCode()  
      static Triple.Meta meta()
      The meta-bean for Triple.
      Triple.Meta<A,​B,​C> metaBean()  
      static <R,​S,​T>
      Triple.Meta<R,​S,​T>
      metaTriple​(java.lang.Class<R> cls1, java.lang.Class<S> cls2, java.lang.Class<T> cls3)
      The meta-bean for Triple.
      static <A,​B,​C>
      Triple<A,​B,​C>
      of​(A first, B second, C third)
      Obtains a triple inferring the types.
      int size()
      Gets the number of elements held by this triple.
      java.lang.String toString()
      Gets the pair using a standard string format.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • of

        public static <A,​B,​C> Triple<A,​B,​C> of​(A first,
                                                                       B second,
                                                                       C third)
        Obtains a triple inferring the types.
        Type Parameters:
        A - the first element type
        B - the second element type
        C - the third element type
        Parameters:
        first - the first element
        second - the second element
        third - the third element
        Returns:
        a triple formed from the three parameters
      • size

        public int size()
        Gets the number of elements held by this triple.
        Specified by:
        size in interface Tuple
        Returns:
        size 3
      • elements

        public com.google.common.collect.ImmutableList<java.lang.Object> elements()
        Gets the elements from this triple as a list.

        The list returns each element in the triple in order.

        Specified by:
        elements in interface Tuple
        Returns:
        the elements as an immutable list
      • compareTo

        public int compareTo​(Triple<A,​B,​C> other)
        Compares the triple based on the first element followed by the second element followed by the third element.

        The element types must be Comparable.

        Specified by:
        compareTo in interface java.lang.Comparable<A>
        Parameters:
        other - the other pair
        Returns:
        negative if this is less, zero if equal, positive if greater
        Throws:
        java.lang.ClassCastException - if either object is not comparable
      • toString

        public java.lang.String toString()
        Gets the pair using a standard string format.

        The standard format is '[$first, $second, $third]'. Spaces around the values are trimmed.

        Overrides:
        toString in class java.lang.Object
        Returns:
        the pair as a string
      • meta

        public static Triple.Meta meta()
        The meta-bean for Triple.
        Returns:
        the meta-bean, not null
      • metaTriple

        public static <R,​S,​T> Triple.Meta<R,​S,​T> metaTriple​(java.lang.Class<R> cls1,
                                                                                    java.lang.Class<S> cls2,
                                                                                    java.lang.Class<T> cls3)
        The meta-bean for Triple.
        Type Parameters:
        R - the first generic type
        S - the second generic type
        T - the second generic type
        Parameters:
        cls1 - the first generic type
        cls2 - the second generic type
        cls3 - the third generic type
        Returns:
        the meta-bean, not null
      • getFirst

        public A getFirst()
        Gets the first element in this pair.
        Returns:
        the value of the property, not null
      • getSecond

        public B getSecond()
        Gets the second element in this pair.
        Returns:
        the value of the property, not null
      • getThird

        public C getThird()
        Gets the third element in this pair.
        Returns:
        the value of the property, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object