Class Semigroups

java.lang.Object
io.atlassian.fugue.Semigroups

public final class Semigroups extends Object
Semigroup instances.
Since:
3.1
See Also:
  • Field Details

    • intMaximum

      public static final Semigroup<Integer> intMaximum
      A semigroup that yields the maximum of integers.
    • intMinimum

      public static final Semigroup<Integer> intMinimum
      A semigroup that yields the minimum of integers.
    • bigintMaximum

      public static final Semigroup<BigInteger> bigintMaximum
      A semigroup that yields the maximum of big integers.
    • bigintMinimum

      public static final Semigroup<BigInteger> bigintMinimum
      A semigroup that yields the minimum of big integers.
    • bigDecimalMaximum

      public static final Semigroup<BigDecimal> bigDecimalMaximum
      A semigroup that yields the maximum of big decimals.
    • bigDecimalMinimum

      public static final Semigroup<BigDecimal> bigDecimalMinimum
      A semigroup that yields the minimum of big decimals.
    • longMaximum

      public static final Semigroup<Long> longMaximum
      A semigroup that yields the maximum of longs.
    • longMinimum

      public static final Semigroup<Long> longMinimum
      A semigroup that yields the minimum of longs.
  • Constructor Details

    • Semigroups

      private Semigroups()
  • Method Details

    • first

      public static <A> Semigroup<A> first()
      Return the first value, ignore the second
      Type Parameters:
      A - result type
      Returns:
      a Semigroup that ignores the second input
    • last

      public static <A> Semigroup<A> last()
      Return the last value, ignore the first
      Type Parameters:
      A - result type
      Returns:
      a Semigroup that ignores the first input
    • function

      public static <A,B> Semigroup<Function<A,B>> function(Semigroup<B> sb)
      A semigroup for functions.
      Type Parameters:
      A - input type
      B - composable output type
      Parameters:
      sb - The semigroup for the codomain.
      Returns:
      A semigroup for functions.
    • max

      public static <A> Semigroup<A> max(Comparator<A> comparator)
      A semigroup that yields the maximum of by a comparator.
      Type Parameters:
      A - result type
      Parameters:
      comparator - the comparator used to define the max of two value.
      Returns:
      A max semigroup.
    • min

      public static <A> Semigroup<A> min(Comparator<A> comparator)
      A semigroup that yields the minimum of by a comparator.
      Type Parameters:
      A - result type
      Parameters:
      comparator - the comparator used to define the min of two value.
      Returns:
      A min semigroup.
    • max

      public static <A extends Comparable<A>> Semigroup<A> max()
      A semigroup that yields the maximum of comparable values.
      Type Parameters:
      A - result type
      Returns:
      A max semigroup.
    • min

      public static <A extends Comparable<A>> Semigroup<A> min()
      A semigroup that yields the minimum of comparable values.
      Type Parameters:
      A - result type
      Returns:
      A min semigroup.
    • either

      public static <L,R> Semigroup<Either<L,R>> either(Semigroup<L> lS, Semigroup<R> rS)
      Sums up values inside either, if both are left or right. Returns first left otherwise.
      • right(v1) + right(v2) → right(v1 + v2)
      • right(v1) + -left(v2) → left(v2)
      • left(v1) + right(v2) → left(v1)
      • left(v1) + left(v2) → left(v1 + v2)
      Type Parameters:
      L - left type
      R - right type
      Parameters:
      lS - Semigroup for left values
      rS - Semigroup for right values
      Returns:
      A semigroup that Sums up values inside either.