Class Pair<U,​V>

  • Type Parameters:
    U - First type
    V - Second type
    All Implemented Interfaces:
    Tuple

    public class Pair<U,​V>
    extends Object
    implements Tuple
    Immutable generic 2-tuple
    • Constructor Detail

      • Pair

        protected Pair​(U first,
                       V second)
    • Method Detail

      • of

        public static <U,​V> @NonNull Pair<U,​V> of​(U first,
                                                              V second)
        Create a new 2-tuple
        Type Parameters:
        U - First type
        V - Second type
        Parameters:
        first - First value
        second - Second value
        Returns:
        Created pair
      • getFirst

        public final U getFirst()
        Get the first value
        Returns:
        First value
      • getSecond

        public final V getSecond()
        Get the second value
        Returns:
        Second value
      • getSize

        public final int getSize()
        Description copied from interface: Tuple
        Get the tuple size
        Specified by:
        getSize in interface Tuple
        Returns:
        Tuple size