Package io.atlassian.fugue
Class Semigroups
- java.lang.Object
-
- io.atlassian.fugue.Semigroups
-
-
Field Summary
Fields Modifier and Type Field Description static Semigroup<java.math.BigDecimal>bigDecimalMaximumA semigroup that yields the maximum of big decimals.static Semigroup<java.math.BigDecimal>bigDecimalMinimumA semigroup that yields the minimum of big decimals.static Semigroup<java.math.BigInteger>bigintMaximumA semigroup that yields the maximum of big integers.static Semigroup<java.math.BigInteger>bigintMinimumA semigroup that yields the minimum of big integers.static Semigroup<java.lang.Integer>intMaximumA semigroup that yields the maximum of integers.static Semigroup<java.lang.Integer>intMinimumA semigroup that yields the minimum of integers.static Semigroup<java.lang.Long>longMaximumA semigroup that yields the maximum of longs.static Semigroup<java.lang.Long>longMinimumA semigroup that yields the minimum of longs.
-
Constructor Summary
Constructors Modifier Constructor Description privateSemigroups()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static <A> Semigroup<A>first()Return the first value, ignore the secondstatic <A,B>
Semigroup<java.util.function.Function<A,B>>function(Semigroup<B> sb)A semigroup for functions.static <A> Semigroup<A>last()Return the last value, ignore the firststatic <A extends java.lang.Comparable<A>>
Semigroup<A>max()A semigroup that yields the maximum of comparable values.static <A> Semigroup<A>max(java.util.Comparator<A> comparator)A semigroup that yields the maximum of by a comparator.static <A extends java.lang.Comparable<A>>
Semigroup<A>min()A semigroup that yields the minimum of comparable values.static <A> Semigroup<A>min(java.util.Comparator<A> comparator)A semigroup that yields the minimum of by a comparator.
-
-
-
Field Detail
-
intMaximum
public static final Semigroup<java.lang.Integer> intMaximum
A semigroup that yields the maximum of integers.
-
intMinimum
public static final Semigroup<java.lang.Integer> intMinimum
A semigroup that yields the minimum of integers.
-
bigintMaximum
public static final Semigroup<java.math.BigInteger> bigintMaximum
A semigroup that yields the maximum of big integers.
-
bigintMinimum
public static final Semigroup<java.math.BigInteger> bigintMinimum
A semigroup that yields the minimum of big integers.
-
bigDecimalMaximum
public static final Semigroup<java.math.BigDecimal> bigDecimalMaximum
A semigroup that yields the maximum of big decimals.
-
bigDecimalMinimum
public static final Semigroup<java.math.BigDecimal> bigDecimalMinimum
A semigroup that yields the minimum of big decimals.
-
longMaximum
public static final Semigroup<java.lang.Long> longMaximum
A semigroup that yields the maximum of longs.
-
longMinimum
public static final Semigroup<java.lang.Long> longMinimum
A semigroup that yields the minimum of longs.
-
-
Method Detail
-
first
public static <A> Semigroup<A> first()
Return the first value, ignore the second- Type Parameters:
A- result type- Returns:
- a
Semigroupthat 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
Semigroupthat ignores the first input
-
function
public static <A,B> Semigroup<java.util.function.Function<A,B>> function(Semigroup<B> sb)
A semigroup for functions.- Type Parameters:
A- input typeB- composable output type- Parameters:
sb- The semigroup for the codomain.- Returns:
- A semigroup for functions.
-
max
public static <A> Semigroup<A> max(java.util.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(java.util.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 java.lang.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 java.lang.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 typeR- right type- Parameters:
lS- Semigroup for left valuesrS- Semigroup for right values- Returns:
- A semigroup that Sums up values inside either.
-
-