Class Tuples

java.lang.Object
eu.bandm.tools.util.anon.Tuples

public abstract class Tuples extends Object
Library of methods operating on the different tuple classes.
  • Method Details

    • tuple

      public static <A0, A1> Tuple2<A0,A1> tuple(@Opt A0 elem0, @Opt A1 elem1)
      Build a 2-tuple.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      Parameters:
      elem0 - the value for the first component.
      elem1 - the value for the second component.
      Returns:
      the corresponding 2-tuple.
    • tuple

      public static <A0, A1, A2> Tuple3<A0,A1,A2> tuple(@Opt A0 elem0, @Opt A1 elem1, @Opt A2 elem2)
      Build a 3-tuple.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      A2 - the type of the third component.
      Parameters:
      elem0 - the value for the first component.
      elem1 - the value for the second component.
      elem2 - the value for the third component.
      Returns:
      the corresponding 3-tuple.
    • tuple

      public static <A0, A1, A2, A3> Tuple4<A0,A1,A2,A3> tuple(@Opt A0 elem0, @Opt A1 elem1, @Opt A2 elem2, @Opt A3 elem3)
      Build a 4-tuple.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      A2 - the type of the third component.
      A3 - the type of the fourth component.
      Parameters:
      elem0 - the value for the first component.
      elem1 - the value for the second component.
      elem2 - the value for the third component.
      elem3 - the value for the fourth component.
      Returns:
      the corresponding 4-tuple.
    • tupling

      public static <A, B0, B1> Function<A,Tuple2<B0,B1>> tupling(Function<A,@Opt B0> f0, Function<A,@Opt B1> f1)
      Build a function which delivers a 2-tuple from functions which deliver a single value.
      Type Parameters:
      A - the common domain of all functions.
      B0 - the range of the first function and type of the first component.
      B1 - the range of the second function and type of the second component.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      Returns:
      the corresponding function from the domain into a 2-tuple.
    • tupling

      public static <A, B0, B1, B2> Function<A,Tuple3<B0,B1,B2>> tupling(Function<A,@Opt B0> f0, Function<A,@Opt B1> f1, Function<A,@Opt B2> f2)
      Build a function which delivers a 3-tuple from functions which deliver a single value.
      Type Parameters:
      A - the common domain of all functions.
      B0 - the range of the first function and type of the first component.
      B1 - the range of the second function and type of the second component.
      B2 - the range of the third function and type of the third component.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      f2 - the third function.
      Returns:
      the corresponding function from the domain into a 3-tuple.
    • tupling

      public static <A, B0, B1, B2, B3> Function<A,Tuple4<B0,B1,B2,B3>> tupling(Function<A,@Opt B0> f0, Function<A,@Opt B1> f1, Function<A,@Opt B2> f2, Function<A,@Opt B3> f3)
      Build a function which delivers a 4-tuple from functions which deliver a single value.
      Type Parameters:
      A - the common domain of all functions.
      B0 - the range of the first function and type of the first component.
      B1 - the range of the second function and type of the second component.
      B2 - the range of the third function and type of the third component.
      B3 - the range of the fourth function and type of the fourth component.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      f2 - the third function.
      f3 - the fourth function.
      Returns:
      the corresponding function from the domain into a 4-tuple.
    • product

      public static <A0, A1, B0, B1> Function<Tuple2<A0,A1>,Tuple2<B0,B1>> product(Function<A0,@Opt B0> f0, Function<A1,@Opt B1> f1)
      Build an operation on tuples from two operations on the component types.
      Type Parameters:
      A0 - the domain of the first function and type of the first component of the inputs.
      A1 - the domain of the second function and type of the second component of the inputs.
      B0 - the range of the first function and type of the first component of the results.
      B1 - the range of the second function and type of the second component of the results.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      Returns:
      the corresponding function on 2-tuples.
    • product

      public static <A0, A1, A2, B0, B1, B2> Function<Tuple3<A0,A1,A2>,Tuple3<B0,B1,B2>> product(Function<A0,@Opt B0> f0, Function<A1,@Opt B1> f1, Function<A2,@Opt B2> f2)
      Build an operation on tuples from three operations on the component types.
      Type Parameters:
      A0 - the domain of the first function and type of the first component of the inputs.
      A1 - the domain of the second function and type of the second component of the inputs.
      A2 - the domain of the third function and type of the third component of the inputs.
      B0 - the range of the first function and type of the first component of the results.
      B1 - the range of the second function and type of the second component of the results.
      B2 - the range of the third function and type of the third component of the results.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      f2 - the third function.
      Returns:
      the corresponding function on 3-tuples.
    • product

      public static <A0, A1, A2, A3, B0, B1, B2, B3> Function<Tuple4<A0,A1,A2,A3>,Tuple4<B0,B1,B2,B3>> product(Function<A0,@Opt B0> f0, Function<A1,@Opt B1> f1, Function<A2,@Opt B2> f2, Function<A3,@Opt B3> f3)
      Build an operation on tuples from four operations on the component types.
      Type Parameters:
      A0 - the domain of the first function and type of the first component of the inputs.
      A1 - the domain of the second function and type of the second component of the inputs.
      A2 - the domain of the third function and type of the third component of the inputs.
      A3 - the domain of the fourth function and type of the fourth component of the inputs.
      B0 - the range of the first function and type of the first component of the results.
      B1 - the range of the second function and type of the second component of the results.
      B2 - the range of the third function and type of the third component of the results.
      B3 - the range of the fourth function and type of the fourth component of the results.
      Parameters:
      f0 - the first function.
      f1 - the second function.
      f2 - the third function.
      f3 - the fourth function.
      Returns:
      the corresponding function on 4-tuples.
    • lexical

      public static <A0, A1> Comparator<Tuple2<A0,A1>> lexical(Comparator<A0> c0, Comparator<A1> c1)
      Combine two comparators of the components into a comparator for the 2-tuple, in lexical style. Whenever a comparator delivers zero, the next in the list is asked.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      Parameters:
      c0 - the comparator for the first component.
      c1 - the comparator for the second component.
      Returns:
      the comparator for the 2-tuple
    • lexical

      public static <A0, A1, A2> Comparator<Tuple3<A0,A1,A2>> lexical(Comparator<A0> c0, Comparator<A1> c1, Comparator<A2> c2)
      Combine two comparators of the components into a comparator for the 3-tuple, in lexical style. Whenever a comparator delivers zero, the next in the list is asked.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      A2 - the type of the third component.
      Parameters:
      c0 - the comparator for the first component.
      c1 - the comparator for the second component.
      c2 - the comparator for the third component.
      Returns:
      the comparator for the 3-tuple
    • lexical

      public static <A0, A1, A2, A3> Comparator<Tuple4<A0,A1,A2,A3>> lexical(Comparator<A0> c0, Comparator<A1> c1, Comparator<A2> c2, Comparator<A3> c3)
      Combine four comparators of the components into a comparator for the 4-tuple, in lexical style. Whenever a comparator delivers zero, the next in the list is asked.
      Type Parameters:
      A0 - the type of the first component.
      A1 - the type of the second component.
      A2 - the type of the third component.
      A3 - the type of the fourth component.
      Parameters:
      c0 - the comparator for the first component.
      c1 - the comparator for the second component.
      c2 - the comparator for the third component.
      c3 - the comparator for the fourth component.
      Returns:
      the comparator for the 4-tuple