Top Description Constructors Methods
org.javamoney.moneta.function

public final Class MonetaryFunctions

extends Object
Class Inheritance
Imports
java.util.Comparator, .List, .Map, .Objects, java.util.function.BinaryOperator, .Predicate, .Supplier, java.util.stream.Collector, .Collectors, javax.money.CurrencyUnit, .MonetaryAmount, .MonetaryException, javax.money.convert.CurrencyConversion, .ExchangeRate, .ExchangeRateProvider, org.javamoney.moneta.spi.MoneyUtils

This singleton class provides access to the predefined monetary functions.
Authors
otaviojava, anatole, keilw

Constructor Summary

AccessConstructor and Description
private
MonetaryFunctions()

Private constructor for static accessor class.

Method Summary

Modifier and TypeMethod and Description
public static Predicate<MonetaryAmount>

Returns:

the predicate from CurrencyUnit
filterByExcludingCurrency
(CurrencyUnit...
the target javax.money.CurrencyUnit instances
currencies
)

Create predicate that filters by CurrencyUnit.

public static Collector<MonetaryAmount, ?, Map<CurrencyUnit, List<MonetaryAmount>>>

Returns:

the Collector to of Map>
groupByCurrencyUnit
()

Collector to group by CurrencyUnit

public static Collector<MonetaryAmount, GroupMonetarySummaryStatistics, GroupMonetarySummaryStatistics>

Returns:

the MonetarySummaryStatistics
groupBySummarizingMonetary
()

of MonetaryAmount group by MonetarySummary

public static Predicate<MonetaryAmount>

Returns:

the Predicate between min and max.
isBetween
(MonetaryAmount
min value inclusive, not null.
min
,
MonetaryAmount
max value inclusive, not null.
max
)

Creates a filter using the isBetween predicate.

public static Predicate<MonetaryAmount>

Returns:

the predicate from CurrencyUnit
isCurrency
(CurrencyUnit... currencies)

Create predicate that filters by CurrencyUnit.

public static Predicate<MonetaryAmount>

Returns:

the filter with isGreaterThan conditions
isGreaterThan
(MonetaryAmount
the amount to be compared to.
amount
)

Creates filter using isGreaterThan in MonetaryAmount.

public static Predicate<MonetaryAmount>

Returns:

the filter with isGreaterThanOrEqualTo conditions
isGreaterThanOrEqualTo
(MonetaryAmount
the amount to be compared to.
amount
)

Creates filter using isGreaterThanOrEqualTo in MonetaryAmount

public static Predicate<MonetaryAmount>

Returns:

the filter with isLessThan conditions
isLessThan
(MonetaryAmount
the amount to be compared to.
amount
)

Creates filter using isLessThan in MonetaryAmount

public static Predicate<MonetaryAmount>

Returns:

the filter with isLessThanOrEqualTo conditions
isLessThanOrEqualTo
(MonetaryAmount
the amount to be compared to.
amount
)

Creates filter using isLessThanOrEqualTo in MonetaryAmount

pack-priv static MonetaryAmount

Returns:

the larger of a and b.
max
(MonetaryAmount
an argument.
a
,
MonetaryAmount
another argument.
b
)

Returns the greater of two MonetaryAmount values.

public static BinaryOperator<MonetaryAmount>

Returns:

the max BinaryOperator, not null.
max
()

Creates a BinaryOperator to calculate the maximum amount.

public static BinaryOperator<MonetaryAmount>

Returns:

the maximum value
max
(ExchangeRateProvider
the ExchangeRateProvider to convert the currencies
provider
)

return the maximum value, if the monetary amounts have different currencies, will converter first using the given ExchangeRateProvider

pack-priv static MonetaryAmount

Returns:

the smaller of a and b.
min
(MonetaryAmount
an argument.
a
,
MonetaryAmount
another argument.
b
)

Returns the smaller of two MonetaryAmount values.

public static BinaryOperator<MonetaryAmount>

Returns:

the minimum BinaryOperator, not null.
min
()

Creates a BinaryOperator to calculate the minimum amount

public static BinaryOperator<MonetaryAmount>

Returns:

the minimum value
min
(ExchangeRateProvider
the ExchangeRateProvider to convert the currencies
provider
)

return the minimum value, if the monetary amounts have different currencies, will converter first using the given ExchangeRateProvider

public static Comparator<MonetaryAmount>

Returns:

the Comparator to sort by CurrencyUnit in ascending order, not null.
sortCurrencyUnit
()

Get a comparator for sorting CurrencyUnits ascending.

public static Comparator<MonetaryAmount>

Returns:

the Comparator to sort by CurrencyUnit in descending order, not null.
sortCurrencyUnitDesc
()

Get a comparator for sorting CurrencyUnits descending.

public static Comparator<MonetaryAmount>

Returns:

the Comparator to sort by number in ascending way, not null.
sortNumber
()

Get a comparator for sorting amount by number value ascending.

public static Comparator<MonetaryAmount>

Returns:

the Comparator to sort by number in descending way, not null.
sortNumberDesc
()

Get a comparator for sorting amount by number value descending.

public static Comparator<? super MonetaryAmount>

Returns:

the sort of MonetaryAmount using ExchangeRate
sortValiable
(final ExchangeRateProvider
the rate provider to be used.
provider
)
Deprecated call #sortValuable instead of.

comparator to sort the MonetaryAmount considering the ExchangeRate

public static Comparator<? super MonetaryAmount>
sortValiableDesc(final ExchangeRateProvider
the rate provider to be used.
provider
)
Deprecated Use #sortValiableDesc instead of.

Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

public static Comparator<? super MonetaryAmount>

Returns:

the sort of MonetaryAmount using ExchangeRate
sortValuable
(ExchangeRateProvider
the rate provider to be used, not null.
provider
)

comparator to sort the MonetaryAmount considering the ExchangeRate

public static Comparator<? super MonetaryAmount>
sortValuableDesc(ExchangeRateProvider
the rate provider to be used, not null.
provider
)

Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

public static MonetaryAmount

Returns:

the sum of a and b
sum
(MonetaryAmount
the first operand
a
,
MonetaryAmount
the second operand
b
)

Adds two monetary together

public static BinaryOperator<MonetaryAmount>

Returns:

the sum BinaryOperator, not null.
sum
()

Creates a BinaryOperator to sum.

public static BinaryOperator<MonetaryAmount>

Returns:

the list convert to specific currency unit
sum
(ExchangeRateProvider
the rate provider to be used, not null.
provider
,
CurrencyUnit
currency
currency
)

return the sum and convert all values to specific currency using the provider, if necessary

public static Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics>

Returns:

the MonetarySummaryStatistics
summarizingMonetary
(CurrencyUnit currencyUnit)

Creates a the summary of MonetaryAmounts.

public static Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics>

Returns:

the MonetarySummaryStatistics
summarizingMonetary
(CurrencyUnit currencyUnit, ExchangeRateProvider
the rate provider
provider
)
Deprecated Use #summarizingMonetary(CurrencyUnit) instead of.

reates a the summary of MonetaryAmounts.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MonetaryFunctionsback to summary
private MonetaryFunctions()

Private constructor for static accessor class.

Method Detail

filterByExcludingCurrencyback to summary
public static Predicate<MonetaryAmount> filterByExcludingCurrency(CurrencyUnit... currencies)

Create predicate that filters by CurrencyUnit.

Parameters
currencies:CurrencyUnit[]

the target javax.money.CurrencyUnit instances

Returns:Predicate<MonetaryAmount>

the predicate from CurrencyUnit

groupByCurrencyUnitback to summary
public static Collector<MonetaryAmount, ?, Map<CurrencyUnit, List<MonetaryAmount>>> groupByCurrencyUnit()

Collector to group by CurrencyUnit

Returns:Collector<MonetaryAmount, ?, Map<CurrencyUnit, List<MonetaryAmount>>>

the Collector to of Map>

groupBySummarizingMonetaryback to summary
public static Collector<MonetaryAmount, GroupMonetarySummaryStatistics, GroupMonetarySummaryStatistics> groupBySummarizingMonetary()

of MonetaryAmount group by MonetarySummary

Returns:Collector<MonetaryAmount, GroupMonetarySummaryStatistics, GroupMonetarySummaryStatistics>

the MonetarySummaryStatistics

isBetweenback to summary
public static Predicate<MonetaryAmount> isBetween(MonetaryAmount min, MonetaryAmount max)

Creates a filter using the isBetween predicate.

Parameters
min:MonetaryAmount

min value inclusive, not null.

max:MonetaryAmount

max value inclusive, not null.

Returns:Predicate<MonetaryAmount>

the Predicate between min and max.

isCurrencyback to summary
public static Predicate<MonetaryAmount> isCurrency(CurrencyUnit... currencies)

Create predicate that filters by CurrencyUnit.

Parameters
currencies:CurrencyUnit[]

the target javax.money.CurrencyUnit

Returns:Predicate<MonetaryAmount>

the predicate from CurrencyUnit

isGreaterThanback to summary
public static Predicate<MonetaryAmount> isGreaterThan(MonetaryAmount amount)

Creates filter using isGreaterThan in MonetaryAmount.

Parameters
amount:MonetaryAmount

the amount to be compared to.

Returns:Predicate<MonetaryAmount>

the filter with isGreaterThan conditions

isGreaterThanOrEqualToback to summary
public static Predicate<MonetaryAmount> isGreaterThanOrEqualTo(MonetaryAmount amount)

Creates filter using isGreaterThanOrEqualTo in MonetaryAmount

Parameters
amount:MonetaryAmount

the amount to be compared to.

Returns:Predicate<MonetaryAmount>

the filter with isGreaterThanOrEqualTo conditions

isLessThanback to summary
public static Predicate<MonetaryAmount> isLessThan(MonetaryAmount amount)

Creates filter using isLessThan in MonetaryAmount

Parameters
amount:MonetaryAmount

the amount to be compared to.

Returns:Predicate<MonetaryAmount>

the filter with isLessThan conditions

isLessThanOrEqualToback to summary
public static Predicate<MonetaryAmount> isLessThanOrEqualTo(MonetaryAmount amount)

Creates filter using isLessThanOrEqualTo in MonetaryAmount

Parameters
amount:MonetaryAmount

the amount to be compared to.

Returns:Predicate<MonetaryAmount>

the filter with isLessThanOrEqualTo conditions

maxback to summary
pack-priv static MonetaryAmount max(MonetaryAmount a, MonetaryAmount b)

Returns the greater of two MonetaryAmount values. If the arguments have the same value, the result is that same value.

Parameters
a:MonetaryAmount

an argument.

b:MonetaryAmount

another argument.

Returns:MonetaryAmount

the larger of a and b.

maxback to summary
public static BinaryOperator<MonetaryAmount> max()

Creates a BinaryOperator to calculate the maximum amount.

Returns:BinaryOperator<MonetaryAmount>

the max BinaryOperator, not null.

maxback to summary
public static BinaryOperator<MonetaryAmount> max(ExchangeRateProvider provider)

return the maximum value, if the monetary amounts have different currencies, will converter first using the given ExchangeRateProvider

Parameters
provider:ExchangeRateProvider

the ExchangeRateProvider to convert the currencies

Returns:BinaryOperator<MonetaryAmount>

the maximum value

minback to summary
pack-priv static MonetaryAmount min(MonetaryAmount a, MonetaryAmount b)

Returns the smaller of two MonetaryAmount values. If the arguments have the same value, the result is that same value.

Parameters
a:MonetaryAmount

an argument.

b:MonetaryAmount

another argument.

Returns:MonetaryAmount

the smaller of a and b.

minback to summary
public static BinaryOperator<MonetaryAmount> min()

Creates a BinaryOperator to calculate the minimum amount

Returns:BinaryOperator<MonetaryAmount>

the minimum BinaryOperator, not null.

minback to summary
public static BinaryOperator<MonetaryAmount> min(ExchangeRateProvider provider)

return the minimum value, if the monetary amounts have different currencies, will converter first using the given ExchangeRateProvider

Parameters
provider:ExchangeRateProvider

the ExchangeRateProvider to convert the currencies

Returns:BinaryOperator<MonetaryAmount>

the minimum value

sortCurrencyUnitback to summary
public static Comparator<MonetaryAmount> sortCurrencyUnit()

Get a comparator for sorting CurrencyUnits ascending.

Returns:Comparator<MonetaryAmount>

the Comparator to sort by CurrencyUnit in ascending order, not null.

sortCurrencyUnitDescback to summary
public static Comparator<MonetaryAmount> sortCurrencyUnitDesc()

Get a comparator for sorting CurrencyUnits descending.

Returns:Comparator<MonetaryAmount>

the Comparator to sort by CurrencyUnit in descending order, not null.

sortNumberback to summary
public static Comparator<MonetaryAmount> sortNumber()

Get a comparator for sorting amount by number value ascending.

Returns:Comparator<MonetaryAmount>

the Comparator to sort by number in ascending way, not null.

sortNumberDescback to summary
public static Comparator<MonetaryAmount> sortNumberDesc()

Get a comparator for sorting amount by number value descending.

Returns:Comparator<MonetaryAmount>

the Comparator to sort by number in descending way, not null.

sortValiableback to summary
public static Comparator<? super MonetaryAmount> sortValiable(final ExchangeRateProvider provider)

Deprecated

call #sortValuable instead of.

comparator to sort the MonetaryAmount considering the ExchangeRate

Parameters
provider:ExchangeRateProvider

the rate provider to be used.

Returns:Comparator<? super MonetaryAmount>

the sort of MonetaryAmount using ExchangeRate

Annotations
@Deprecated
sortValiableDescback to summary
public static Comparator<? super MonetaryAmount> sortValiableDesc(final ExchangeRateProvider provider)

Deprecated

Use #sortValiableDesc instead of.

Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

Parameters
provider:ExchangeRateProvider

the rate provider to be used.

Returns:Comparator<? super MonetaryAmount>

the Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

Annotations
@Deprecated
sortValuableback to summary
public static Comparator<? super MonetaryAmount> sortValuable(ExchangeRateProvider provider)

comparator to sort the MonetaryAmount considering the ExchangeRate

Parameters
provider:ExchangeRateProvider

the rate provider to be used, not null.

Returns:Comparator<? super MonetaryAmount>

the sort of MonetaryAmount using ExchangeRate

sortValuableDescback to summary
public static Comparator<? super MonetaryAmount> sortValuableDesc(ExchangeRateProvider provider)

Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

Parameters
provider:ExchangeRateProvider

the rate provider to be used, not null.

Returns:Comparator<? super MonetaryAmount>

the Descending order of MonetaryFunctions#sortValuable(ExchangeRateProvider)

sumback to summary
public static MonetaryAmount sum(MonetaryAmount a, MonetaryAmount b)

Adds two monetary together

Parameters
a:MonetaryAmount

the first operand

b:MonetaryAmount

the second operand

Returns:MonetaryAmount

the sum of a and b

Exceptions
NullPointerException:
if a o b be null
MonetaryException:
if a and b have different currency
sumback to summary
public static BinaryOperator<MonetaryAmount> sum()

Creates a BinaryOperator to sum.

Returns:BinaryOperator<MonetaryAmount>

the sum BinaryOperator, not null.

sumback to summary
public static BinaryOperator<MonetaryAmount> sum(ExchangeRateProvider provider, CurrencyUnit currency)

return the sum and convert all values to specific currency using the provider, if necessary

Parameters
provider:ExchangeRateProvider

the rate provider to be used, not null.

currency:CurrencyUnit

currency

Returns:BinaryOperator<MonetaryAmount>

the list convert to specific currency unit

summarizingMonetaryback to summary
public static Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics> summarizingMonetary(CurrencyUnit currencyUnit)

Creates a the summary of MonetaryAmounts.

Parameters
currencyUnit:CurrencyUnit

the target javax.money.CurrencyUnit

Returns:Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics>

the MonetarySummaryStatistics

summarizingMonetaryback to summary
public static Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics> summarizingMonetary(CurrencyUnit currencyUnit, ExchangeRateProvider provider)

Deprecated

Use #summarizingMonetary(CurrencyUnit) instead of.

reates a the summary of MonetaryAmounts.

Parameters
currencyUnit:CurrencyUnit

the target javax.money.CurrencyUnit

provider:ExchangeRateProvider

the rate provider

Returns:Collector<MonetaryAmount, MonetarySummaryStatistics, MonetarySummaryStatistics>

the MonetarySummaryStatistics

Annotations
@Deprecated