Class Tuple<A,​B>

  • Type Parameters:
    A - first value
    B - second value

    public class Tuple<A,​B>
    extends Object
    Immutable object to keep context of two values
    Since:
    1.3.0
    Author:
    afarre
    • Constructor Summary

      Constructors 
      Constructor Description
      Tuple​(A _first, B _second)
      Tuple constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(Object _tuple)  
      A getLeft()
      Getter for left value
      B getRight()
      Getter for right value
      int hashCode()  
      A left()
      return left value
      <C> Tuple<C,​B> left​(C _newValue)
      Create a clone tuple with the left value replaced with the given one
      <C> Tuple<C,​B> left​(Function<A,​C> _converter)
      Create a clone tuple with the left value result of the current left value applying the given converter
      static <LEFT,​RIGHT>
      Tuple<LEFT,​RIGHT>
      of​(LEFT _left, RIGHT _right)
      Create a new Tuple form scratch with the given values
      B right()
      return right value
      <C> Tuple<A,​C> right​(C _newValue)
      Create a clone tuple with the right value replaced with the given one
      <C> Tuple<A,​C> right​(Function<B,​C> _converter)
      Create a clone tuple with the right value result of the current right value applying the given converter
      String toString()  
      <C,​D>
      Tuple<C,​D>
      with​(C _left, D _right)
      Create a clone tuple with the new given values
      <C,​D>
      Tuple<C,​D>
      with​(Function<A,​C> _leftConverter, Function<B,​D> _rightConverter)
      Create a clone tuple with the left and right values converted with the given converters
    • Constructor Detail

      • Tuple

        public Tuple​(A _first,
                     B _second)
        Tuple constructor
        Parameters:
        _first - first param
        _second - second param
    • Method Detail

      • getLeft

        public A getLeft()
        Getter for left value
        Returns:
        left value
      • left

        public A left()
        return left value
        Returns:
        left value
      • getRight

        public B getRight()
        Getter for right value
        Returns:
        right value
      • right

        public B right()
        return right value
        Returns:
        right value
      • left

        public <C> Tuple<C,​B> left​(C _newValue)
        Create a clone tuple with the left value replaced with the given one
        Type Parameters:
        C - type of the new left value
        Parameters:
        _newValue - new value to replace in the cloned tuple
        Returns:
        clone of this tuple with the left value replaced by _newValue
      • left

        public <C> Tuple<C,​B> left​(Function<A,​C> _converter)
        Create a clone tuple with the left value result of the current left value applying the given converter
        Type Parameters:
        C - type of the new left value
        Parameters:
        _converter - function to convert the left value
        Returns:
        clone of this tuple with the left value replaced with the result of apply _converter to the current left value
        Since:
        1.7.0
      • right

        public <C> Tuple<A,​C> right​(C _newValue)
        Create a clone tuple with the right value replaced with the given one
        Type Parameters:
        C - type of the new right value
        Parameters:
        _newValue - new value to replace in the cloned tuple
        Returns:
        clone of this tuple with the right value replaced by _newValue
      • right

        public <C> Tuple<A,​C> right​(Function<B,​C> _converter)
        Create a clone tuple with the right value result of the current right value applying the given converter
        Type Parameters:
        C - type of the new right value
        Parameters:
        _converter - function to convert the right value
        Returns:
        clone of this tuple with the right value replaced with the result of apply _converter to the current right value
        Since:
        1.7.0
      • with

        public <C,​D> Tuple<C,​D> with​(C _left,
                                                 D _right)
        Create a clone tuple with the new given values
        Type Parameters:
        C - type of the new left value
        D - type of the new right value
        Parameters:
        _left - new left value to replace in the cloned tuple
        _right - new right value to replace in the cloned tuple
        Returns:
        clone of this tuple with the right and the left values replaced
      • with

        public <C,​D> Tuple<C,​D> with​(Function<A,​C> _leftConverter,
                                                 Function<B,​D> _rightConverter)
        Create a clone tuple with the left and right values converted with the given converters
        Type Parameters:
        C - type of the new left value
        D - type of the new right value
        Parameters:
        _leftConverter - function to convert the right value
        _rightConverter - function to convert the right value
        Returns:
        clone of this tuple with the right and left value replaced with the result of apply _converters to the current values
        Since:
        1.7.0
      • of

        public static final <LEFT,​RIGHT> Tuple<LEFT,​RIGHT> of​(LEFT _left,
                                                                          RIGHT _right)
        Create a new Tuple form scratch with the given values
        Type Parameters:
        LEFT - type of the new left value
        RIGHT - type of the new right value
        Parameters:
        _left - left value
        _right - right value
        Returns:
        new Tuple form scratch with the given values