java.lang.Object
javax.money.AbstractContext
javax.money.convert.ConversionContext
- All Implemented Interfaces:
java.io.Serializable
public final class ConversionContext extends AbstractContext
This class models a context for which a
ExchangeRate
is valid. It allows to define
different settings such as
- the required
RateType
, - the required target timestamp
- the required validity duration
- additional non standard or extended attributes determined by the implementations participating in the ExchangeRateProvider chain.
- Author:
- Anatole Tresch
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static ConversionContext
ANY_CONVERSION
ConversionContext that queries any conversion available.static ConversionContext
DEFERRED_CONVERSION
ConversionContext querying for any deferred rates.static ConversionContext
HISTORIC_CONVERSION
ConversionContext querying for any historic rates.static ConversionContext
OTHER_CONVERSION
ConversionContext querying for any other rates.static ConversionContext
REALTIME_CONVERSION
ConversionContext querying for real-time rates. -
Method Summary
Modifier and Type Method Description static ConversionContext
from(ProviderContext providerContext, RateType rateType)
Creates a new ConversionContext for the givenProviderContext
and the givenRateType
.java.lang.String
getProviderName()
Get the provider of this rate.RateType
getRateType()
Get the deferred flag.static ConversionContext
of()
Simple factory method forConversionContext
.static ConversionContext
of(java.lang.String provider, RateType rateType)
Simple factory method forConversionContext
.static ConversionContext
of(RateType rateType)
Creates aConversionContext
for accessing rates of the given type, without specifying the rate's provider.ConversionContextBuilder
toBuilder()
Creates a conversion query builder with the context data from this context instance.ConversionQueryBuilder
toQueryBuilder()
Creates a query builder based on this context.
-
Field Details
-
ANY_CONVERSION
ConversionContext that queries any conversion available. -
DEFERRED_CONVERSION
ConversionContext querying for any deferred rates. -
HISTORIC_CONVERSION
ConversionContext querying for any historic rates. -
REALTIME_CONVERSION
ConversionContext querying for real-time rates. -
OTHER_CONVERSION
ConversionContext querying for any other rates.
-
-
Method Details
-
getRateType
Get the deferred flag. Exchange rates can be deferred or real.time.- Returns:
- the deferred flag, or {code null}.
-
getProviderName
public java.lang.String getProviderName()Get the provider of this rate. The provider of a rate can have different contexts in different usage scenarios, such as the service type or the stock exchange.- Overrides:
getProviderName
in classAbstractContext
- Returns:
- the provider, or {code null}.
-
toBuilder
Creates a conversion query builder with the context data from this context instance.- Returns:
- a corresponding conversion query builder instance, never null.
-
toQueryBuilder
Creates a query builder based on this context.- Returns:
- a new instance of
ConversionQueryBuilder
, never null.
-
of
Simple factory method forConversionContext
. For more possibilities to initialize aConversionContext
, please use aConversionContextBuilder
,- Parameters:
provider
- the provider name, notnull
rateType
- the required rate type.- Returns:
- a new instance of
ConversionContext
-
from
Creates a new ConversionContext for the givenProviderContext
and the givenRateType
.Note: for adding additional attributes use
(ProviderContext, RateType)
.- Parameters:
providerContext
- the provider context, not null.rateType
- the rate type, not null.- Returns:
- a corresponding instance of ConversionContext.
-
of
Creates aConversionContext
for accessing rates of the given type, without specifying the rate's provider.- Parameters:
rateType
- the required rate type.- Returns:
- a new instance of
ConversionContext
-
of
Simple factory method forConversionContext
. For more possibilities to initialize aConversionContext
, please use aConversionContextBuilder
,- Returns:
- a new instance of
ConversionContext
-