Class Triple<T1,​T2,​T3>

  • Type Parameters:
    T1 - the first element type
    T2 - the second element type
    T3 - the third element type
    All Implemented Interfaces:
    Tuple<Triple<T1,​T2,​T3>>, Serializable

    public class Triple<T1,​T2,​T3>
    extends Object
    implements Tuple<Triple<T1,​T2,​T3>>
    Represents a Tuple with three elements.
    Note: Triple supports equals(Object) comparison using subclasses, e.g.:
    
         public class LeftMiddleAndRightSide extends Triple<String, String, String> {
    
             public LeftMiddleAndRightSide(String leftSide, String middle, String rightSide) {
                 super(leftSide, middle, rightSide);
             }
         }
     
    See Also:
    Serialized Form
    • Field Detail

      • _1

        public final T1 _1
        The first element in this tuple
      • _2

        public final T2 _2
        The second element in this tuple
      • _3

        public final T3 _3
        The third element in this tuple
    • Constructor Detail

      • Triple

        public Triple​(T1 t1,
                      T2 t2,
                      T3 t3)
        Construct a new Tuple with 3 elements
        Parameters:
        t1 - the first element
        t2 - the second element
        t3 - the third element
    • Method Detail

      • arity

        public int arity()
        Description copied from interface: Tuple
        Number of arguments/elements in the Tuple
        Specified by:
        arity in interface Tuple<T1>
        Returns:
        Number of arguments/elements in the Tuple
      • toList

        public List<?> toList()
        Description copied from interface: Tuple
        Convert the Tuple to a list
        Specified by:
        toList in interface Tuple<T1>
        Returns:
        list of all Tuple elements
      • _1

        public T1 _1()
        The first element in this tuple
        Returns:
        The first element in this tuple
      • _2

        public T2 _2()
        The second element in this tuple
        Returns:
        The second element in this tuple
      • _3

        public T3 _3()
        The third element in this tuple
        Returns:
        The third element in this tuple
      • map

        public <R1,​R2,​R3> Triple<R1,​R2,​R3> map​(TripleFunction<? super T1,​? super T2,​? super T3,​Triple<R1,​R2,​R3>> mappingFunction)
        Maps the elements of this Triple using the mapping function
        Type Parameters:
        R1 - result type for first element of the Triple after applying the mapping function
        R2 - result type for second element of the Triple after applying the mapping function
        R3 - result type for third element of the Triple after applying the mapping function
        Parameters:
        mappingFunction - the mapping function
        Returns:
        a new Triple with the result of applying the mapping function to this Triple
      • map

        public <R1,​R2,​R3> Triple<R1,​R2,​R3> map​(Function<? super T1,​? super R1> mappingFunction1,
                                                                       Function<? super T2,​? super R2> mappingFunction2,
                                                                       Function<? super T3,​? super R3> mappingFunction3)
        Maps the elements of this Triple using three distinct mapping functions
        Type Parameters:
        R1 - result type for first element of the Triple after applying the mapping function
        R2 - result type for second element of the Triple after applying the mapping function
        R3 - result type for third element of the Triple after applying the mapping function
        Parameters:
        mappingFunction1 - the mapping function for element number 1
        mappingFunction2 - the mapping function for element number 2
        mappingFunction3 - the mapping function for element number 3
        Returns:
        a new Triple with the result of applying the mapping function to this Triple
      • map1

        public <R1> Triple<R1,​T2,​T3> map1​(Function<? super T1,​? super R1> mappingFunction1)
        Map the first element of this Triple using the mapping function
        Type Parameters:
        R1 - result type for first element of the Triple after applying the mapping function
        Parameters:
        mappingFunction1 - the mapping function for element number 1
        Returns:
        a new Triple with the result of applying the mapping function to the first element of this Triple
      • map2

        public <R2> Triple<T1,​R2,​T3> map2​(Function<? super T2,​? super R2> mappingFunction2)
        Map the second element of this Triple using the mapping function
        Type Parameters:
        R2 - result type for second element of the Triple after applying the mapping function
        Parameters:
        mappingFunction2 - the mapping function for element number 2
        Returns:
        a new Triple with the result of applying the mapping function to the second element of this Triple
      • map3

        public <R3> Triple<T1,​T2,​R3> map3​(Function<? super T3,​? super R3> mappingFunction3)
        Map the third element of this Triple using the mapping function
        Type Parameters:
        R3 - result type for third element of the Triple after applying the mapping function
        Parameters:
        mappingFunction3 - the mapping function for element number 3
        Returns:
        a new Triple with the result of applying the mapping function to the third element of this Triple
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object