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 ConversionContextANY_CONVERSIONConversionContext that queries any conversion available.static ConversionContextDEFERRED_CONVERSIONConversionContext querying for any deferred rates.static ConversionContextHISTORIC_CONVERSIONConversionContext querying for any historic rates.static ConversionContextOTHER_CONVERSIONConversionContext querying for any other rates.static ConversionContextREALTIME_CONVERSIONConversionContext querying for real-time rates. -
Method Summary
Modifier and Type Method Description static ConversionContextfrom(ProviderContext providerContext, RateType rateType)Creates a new ConversionContext for the givenProviderContextand the givenRateType.java.lang.StringgetProviderName()Get the provider of this rate.RateTypegetRateType()Get the deferred flag.static ConversionContextof()Simple factory method forConversionContext.static ConversionContextof(java.lang.String provider, RateType rateType)Simple factory method forConversionContext.static ConversionContextof(RateType rateType)Creates aConversionContextfor accessing rates of the given type, without specifying the rate's provider.ConversionContextBuildertoBuilder()Creates a conversion query builder with the context data from this context instance.ConversionQueryBuildertoQueryBuilder()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:
getProviderNamein 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, notnullrateType- the required rate type.- Returns:
- a new instance of
ConversionContext
-
from
Creates a new ConversionContext for the givenProviderContextand 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 aConversionContextfor 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
-