Class Joiners

java.lang.Object
org.optaplanner.core.api.score.stream.Joiners

public final class Joiners extends Object
Creates an BiJoiner, TriJoiner, ... instance for use in UniConstraintStream.join(Class, BiJoiner), ...
  • Method Details

    • equal

      public static <A> BiJoiner<A,A> equal()
      As defined by equal(Function) with Function.identity() as the argument.
      Type Parameters:
      A - the type of both objects
      Returns:
      never null
    • equal

      public static <A, Property_> BiJoiner<A,A> equal(Function<A,Property_> mapping)
      As defined by equal(Function, Function) with both arguments using the same mapping.
      Type Parameters:
      A - the type of both objects
      Property_ - the type of the property to compare
      Parameters:
      mapping - mapping function to apply to both A and B
      Returns:
      never null
    • equal

      public static <A, B, Property_> BiJoiner<A,B> equal(Function<A,Property_> leftMapping, Function<B,Property_> rightMapping)
      Joins every A and B that share a property. These are exactly the pairs where leftMapping.apply(A).equals(rightMapping.apply(B)). For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with both leftMapping and rightMapping being Person::getAge, this joiner will produce pairs (Ann, Ann), (Ann, Eric), (Beth, Beth), (Eric, Ann), (Eric, Eric).
      Type Parameters:
      B - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to A
      rightMapping - mapping function to apply to B
      Returns:
      never null
    • lessThan

      public static <A, Property_ extends Comparable<Property_>> BiJoiner<A,A> lessThan(Function<A,Property_> mapping)
      As defined by lessThan(Function, Function) with both arguments using the same mapping.
      Type Parameters:
      A - the type of both objects
      Property_ - the type of the property to compare
      Parameters:
      mapping - mapping function to apply
      Returns:
      never null
    • lessThan

      public static <A, B, Property_ extends Comparable<Property_>> BiJoiner<A,B> lessThan(Function<A,Property_> leftMapping, Function<B,Property_> rightMapping)
      Joins every A and B where a value of property on A is less than the value of a property on B. These are exactly the pairs where leftMapping.apply(A).compareTo(rightMapping.apply(B)) < 0. For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with both leftMapping and rightMapping being Person::getAge, this joiner will produce pairs (Ann, Beth), (Eric, Beth).
      Type Parameters:
      A - the type of object on the left
      B - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to A
      rightMapping - mapping function to apply to B
      Returns:
      never null
    • lessThanOrEqual

      public static <A, Property_ extends Comparable<Property_>> BiJoiner<A,A> lessThanOrEqual(Function<A,Property_> mapping)
      As defined by lessThanOrEqual(Function, Function) with both arguments using the same mapping.
      Type Parameters:
      A - the type of both objects
      Property_ - the type of the property to compare
      Parameters:
      mapping - mapping function to apply
      Returns:
      never null
    • lessThanOrEqual

      public static <A, B, Property_ extends Comparable<Property_>> BiJoiner<A,B> lessThanOrEqual(Function<A,Property_> leftMapping, Function<B,Property_> rightMapping)
      Joins every A and B where a value of property on A is less than or equal to the value of a property on B. These are exactly the pairs where leftMapping.apply(A).compareTo(rightMapping.apply(B)) <= 0. For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with both leftMapping and rightMapping being Person::getAge, this joiner will produce pairs (Ann, Ann), (Ann, Beth), (Ann, Eric), (Beth, Beth), (Eric, Ann), (Eric, Beth), (Eric, Eric).
      Type Parameters:
      A - the type of object on the left
      B - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to A
      rightMapping - mapping function to apply to B
      Returns:
      never null
    • greaterThan

      public static <A, Property_ extends Comparable<Property_>> BiJoiner<A,A> greaterThan(Function<A,Property_> mapping)
      As defined by greaterThan(Function, Function) with both arguments using the same mapping.
      Type Parameters:
      A - the type of both objects
      Property_ - the type of the property to compare
      Parameters:
      mapping - mapping function to apply
      Returns:
      never null
    • greaterThan

      public static <A, B, Property_ extends Comparable<Property_>> BiJoiner<A,B> greaterThan(Function<A,Property_> leftMapping, Function<B,Property_> rightMapping)
      Joins every A and B where a value of property on A is greater than the value of a property on B. These are exactly the pairs where leftMapping.apply(A).compareTo(rightMapping.apply(B)) > 0. For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with both leftMapping and rightMapping being Person::getAge, this joiner will produce pairs (Beth, Ann), (Beth, Eric).
      Type Parameters:
      A - the type of object on the left
      B - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to A
      rightMapping - mapping function to apply to B
      Returns:
      never null
    • greaterThanOrEqual

      public static <A, Property_ extends Comparable<Property_>> BiJoiner<A,A> greaterThanOrEqual(Function<A,Property_> mapping)
      As defined by greaterThanOrEqual(Function, Function) with both arguments using the same mapping.
      Type Parameters:
      A - the type of both objects
      Property_ - the type of the property to compare
      Parameters:
      mapping - mapping function to apply
      Returns:
      never null
    • greaterThanOrEqual

      public static <A, B, Property_ extends Comparable<Property_>> BiJoiner<A,B> greaterThanOrEqual(Function<A,Property_> leftMapping, Function<B,Property_> rightMapping)
      Joins every A and B where a value of property on A is greater than or equal to the value of a property on B. These are exactly the pairs where leftMapping.apply(A).compareTo(rightMapping.apply(B)) >= 0. For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with both leftMapping and rightMapping being Person::getAge, this joiner will produce pairs (Ann, Ann), (Ann, Eric), (Beth, Ann), (Beth, Beth), (Beth, Eric), (Eric, Ann), (Eric, Eric).
      Type Parameters:
      A - the type of object on the left
      B - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to A
      rightMapping - mapping function to apply to B
      Returns:
      never null
    • filtering

      public static <A, B> BiJoiner<A,B> filtering(BiPredicate<A,B> filter)
      Applies a filter to the joined tuple, with the semantics of BiConstraintStream.filter(BiPredicate). For example, on a cartesian product of list [Ann(age = 20), Beth(age = 25), Eric(age = 20)] with filter being age == 20, this joiner will produce pairs (Ann, Ann), (Ann, Eric), (Eric, Ann), (Eric, Eric).
      Type Parameters:
      A - type of the first fact in the tuple
      B - type of the second fact in the tuple
      Parameters:
      filter - never null, filter to apply
      Returns:
      never null
    • overlapping

      public static <A, Property_ extends Comparable<Property_>> BiJoiner<A,A> overlapping(Function<A,Property_> startMapping, Function<A,Property_> endMapping)
      Joins every A and B that overlap for an interval which is specified by a start and end property on both A and B. These are exactly the pairs where A.start < B.end and A.end > B.start. For example, on a cartesian product of list [Ann(start=08:00, end=14:00), Beth(start=12:00, end=18:00), Eric(start=16:00, end=22:00)] with startMapping being Person::getStart and endMapping being Person::getEnd, this joiner will produce pairs (Ann, Ann), (Ann, Beth), (Beth, Ann), (Beth, Beth), (Beth, Eric), (Eric, Beth), (Eric, Eric).
      Type Parameters:
      A - the type of both the first and second argument
      Property_ - the type used to define the interval, comparable
      Parameters:
      startMapping - maps the argument to the start point of its interval (inclusive)
      endMapping - maps the argument to the end point of its interval (exclusive)
      Returns:
      never null
    • overlapping

      public static <A, B, Property_ extends Comparable<Property_>> BiJoiner<A,B> overlapping(Function<A,Property_> leftStartMapping, Function<A,Property_> leftEndMapping, Function<B,Property_> rightStartMapping, Function<B,Property_> rightEndMapping)
      Type Parameters:
      A - the type of the first argument
      B - the type of the second argument
      Property_ - the type used to define the interval, comparable
      Parameters:
      leftStartMapping - maps the first argument to its interval start point (inclusive)
      leftEndMapping - maps the first argument to its interval end point (exclusive)
      rightStartMapping - maps the second argument to its interval start point (inclusive)
      rightEndMapping - maps the second argument to its interval end point (exclusive)
      Returns:
      never null
    • equal

      public static <A, B, C, Property_> TriJoiner<A,B,C> equal(BiFunction<A,B,Property_> leftMapping, Function<C,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B)
      rightMapping - mapping function to apply to C
      Returns:
      never null
    • lessThan

      public static <A, B, C, Property_ extends Comparable<Property_>> TriJoiner<A,B,C> lessThan(BiFunction<A,B,Property_> leftMapping, Function<C,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B)
      rightMapping - mapping function to apply to C
      Returns:
      never null
    • lessThanOrEqual

      public static <A, B, C, Property_ extends Comparable<Property_>> TriJoiner<A,B,C> lessThanOrEqual(BiFunction<A,B,Property_> leftMapping, Function<C,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B)
      rightMapping - mapping function to apply to C
      Returns:
      never null
    • greaterThan

      public static <A, B, C, Property_ extends Comparable<Property_>> TriJoiner<A,B,C> greaterThan(BiFunction<A,B,Property_> leftMapping, Function<C,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B)
      rightMapping - mapping function to apply to C
      Returns:
      never null
    • greaterThanOrEqual

      public static <A, B, C, Property_ extends Comparable<Property_>> TriJoiner<A,B,C> greaterThanOrEqual(BiFunction<A,B,Property_> leftMapping, Function<C,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B)
      rightMapping - mapping function to apply to C
      Returns:
      never null
    • filtering

      public static <A, B, C> TriJoiner<A,B,C> filtering(TriPredicate<A,B,C> filter)
      As defined by filtering(BiPredicate).
      Type Parameters:
      A - type of the first fact in the tuple
      B - type of the second fact in the tuple
      C - type of the third fact in the tuple
      Parameters:
      filter - never null, filter to apply
      Returns:
      never null
    • overlapping

      public static <A, B, C, Property_ extends Comparable<Property_>> TriJoiner<A,B,C> overlapping(BiFunction<A,B,Property_> leftStartMapping, BiFunction<A,B,Property_> leftEndMapping, Function<C,Property_> rightStartMapping, Function<C,Property_> rightEndMapping)
      Type Parameters:
      A - the type of the first argument
      B - the type of the second argument
      C - the type of the third argument
      Property_ - the type used to define the interval, comparable
      Parameters:
      leftStartMapping - maps the first and second arguments to their interval start point (inclusive)
      leftEndMapping - maps the first and second arguments to their interval end point (exclusive)
      rightStartMapping - maps the third argument to its interval start point (inclusive)
      rightEndMapping - maps the third argument to its interval end point (exclusive)
      Returns:
      never null
    • equal

      public static <A, B, C, D, Property_> QuadJoiner<A,B,C,D> equal(TriFunction<A,B,C,Property_> leftMapping, Function<D,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A, B, C)
      rightMapping - mapping function to apply to D
      Returns:
      never null
    • lessThan

      public static <A, B, C, D, Property_ extends Comparable<Property_>> QuadJoiner<A,B,C,D> lessThan(TriFunction<A,B,C,Property_> leftMapping, Function<D,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C)
      rightMapping - mapping function to apply to D
      Returns:
      never null
    • lessThanOrEqual

      public static <A, B, C, D, Property_ extends Comparable<Property_>> QuadJoiner<A,B,C,D> lessThanOrEqual(TriFunction<A,B,C,Property_> leftMapping, Function<D,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C)
      rightMapping - mapping function to apply to D
      Returns:
      never null
    • greaterThan

      public static <A, B, C, D, Property_ extends Comparable<Property_>> QuadJoiner<A,B,C,D> greaterThan(TriFunction<A,B,C,Property_> leftMapping, Function<D,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C)
      rightMapping - mapping function to apply to D
      Returns:
      never null
    • greaterThanOrEqual

      public static <A, B, C, D, Property_ extends Comparable<Property_>> QuadJoiner<A,B,C,D> greaterThanOrEqual(TriFunction<A,B,C,Property_> leftMapping, Function<D,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C)
      rightMapping - mapping function to apply to D
      Returns:
      never null
    • filtering

      public static <A, B, C, D> QuadJoiner<A,B,C,D> filtering(QuadPredicate<A,B,C,D> filter)
      As defined by filtering(BiPredicate).
      Type Parameters:
      A - type of the first fact in the tuple
      B - type of the second fact in the tuple
      C - type of the third fact in the tuple
      D - type of the fourth fact in the tuple
      Parameters:
      filter - never null, filter to apply
      Returns:
      never null
    • overlapping

      public static <A, B, C, D, Property_ extends Comparable<Property_>> QuadJoiner<A,B,C,D> overlapping(TriFunction<A,B,C,Property_> leftStartMapping, TriFunction<A,B,C,Property_> leftEndMapping, Function<D,Property_> rightStartMapping, Function<D,Property_> rightEndMapping)
      Type Parameters:
      A - the type of the first argument
      B - the type of the second argument
      C - the type of the third argument
      D - the type of the fourth argument
      Property_ - the type used to define the interval, comparable
      Parameters:
      leftStartMapping - maps the first, second and third arguments to their interval start point (inclusive)
      leftEndMapping - maps the first, second and third arguments to their interval end point (exclusive)
      rightStartMapping - maps the fourth argument to its interval start point (inclusive)
      rightEndMapping - maps the fourth argument to its interval end point (exclusive)
      Returns:
      never null
    • equal

      public static <A, B, C, D, E, Property_> PentaJoiner<A,B,C,D,E> equal(QuadFunction<A,B,C,D,Property_> leftMapping, Function<E,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of the object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C,D)
      rightMapping - mapping function to apply to E
      Returns:
      never null
    • lessThan

      public static <A, B, C, D, E, Property_ extends Comparable<Property_>> PentaJoiner<A,B,C,D,E> lessThan(QuadFunction<A,B,C,D,Property_> leftMapping, Function<E,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C,D)
      rightMapping - mapping function to apply to E
      Returns:
      never null
    • lessThanOrEqual

      public static <A, B, C, D, E, Property_ extends Comparable<Property_>> PentaJoiner<A,B,C,D,E> lessThanOrEqual(QuadFunction<A,B,C,D,Property_> leftMapping, Function<E,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C,D)
      rightMapping - mapping function to apply to E
      Returns:
      never null
    • greaterThan

      public static <A, B, C, D, E, Property_ extends Comparable<Property_>> PentaJoiner<A,B,C,D,E> greaterThan(QuadFunction<A,B,C,D,Property_> leftMapping, Function<E,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C,D)
      rightMapping - mapping function to apply to E
      Returns:
      never null
    • greaterThanOrEqual

      public static <A, B, C, D, E, Property_ extends Comparable<Property_>> PentaJoiner<A,B,C,D,E> greaterThanOrEqual(QuadFunction<A,B,C,D,Property_> leftMapping, Function<E,Property_> rightMapping)
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of object on the right
      Property_ - the type of the property to compare
      Parameters:
      leftMapping - mapping function to apply to (A,B,C,D)
      rightMapping - mapping function to apply to E
      Returns:
      never null
    • filtering

      public static <A, B, C, D, E> PentaJoiner<A,B,C,D,E> filtering(PentaPredicate<A,B,C,D,E> filter)
      As defined by filtering(BiPredicate).
      Type Parameters:
      A - the type of the first object on the left
      B - the type of the second object on the left
      C - the type of the third object on the left
      D - the type of the fourth object on the left
      E - the type of object on the right
      Parameters:
      filter - never null, filter to apply
      Returns:
      never null
    • overlapping

      public static <A, B, C, D, E, Property_ extends Comparable<Property_>> PentaJoiner<A,B,C,D,E> overlapping(QuadFunction<A,B,C,D,Property_> leftStartMapping, QuadFunction<A,B,C,D,Property_> leftEndMapping, Function<E,Property_> rightStartMapping, Function<E,Property_> rightEndMapping)
      Type Parameters:
      A - the type of the first argument
      B - the type of the second argument
      C - the type of the third argument
      D - the type of the fourth argument
      E - the type of the fifth argument
      Property_ - the type used to define the interval, comparable
      Parameters:
      leftStartMapping - maps the first, second, third and fourth arguments to their interval start point (inclusive)
      leftEndMapping - maps the first, second, third and fourth arguments to their interval end point (exclusive)
      rightStartMapping - maps the fifth argument to its interval start point (inclusive)
      rightEndMapping - maps the fifth argument to its interval end point (exclusive)
      Returns:
      never null