Module java.money
Package javax.money
Class AbstractContextBuilder<B extends AbstractContextBuilder,C extends AbstractContext>
- java.lang.Object
-
- javax.money.AbstractContextBuilder<B,C>
-
- Direct Known Subclasses:
AbstractQueryBuilder,AmountFormatContextBuilder,ConversionContextBuilder,CurrencyContextBuilder,MonetaryContextBuilder,ProviderContextBuilder,RoundingContextBuilder
public abstract class AbstractContextBuilder<B extends AbstractContextBuilder,C extends AbstractContext> extends java.lang.ObjectThis interface defines the common generic parts of a query. Queries are used to pass complex parameters sets to lookup monetary artifacts, e.g.MonetaryAmountFactory,MonetaryRounding,CurrencyUnit,ExchangeRateProviderand.CurrencyConversion.Instances of this class are not thread-safe and not serializable.
-
-
Constructor Summary
Constructors Constructor Description AbstractContextBuilder()
-
Method Summary
Modifier and Type Method Description abstract Cbuild()Creates a newAbstractContextwith the data from this Builder instance.BimportContext(AbstractContext context)Apply all attributes on the given context, hereby existing entries are preserved.BimportContext(AbstractContext context, boolean overwriteDuplicates)Apply all attributes on the given context.BremoveAttributes(java.lang.String... keys)Removes an entry of a certain keys.<T> Bset(java.lang.Class<T> key, T value)Sets an attribute, usingattribute.getClass()as attribute type.Bset(java.lang.Object value)Sets an attribute, usingattribute.getClass()as attribute type andattribute.getClass().getName()as attribute name.Bset(java.lang.String key, boolean value)Sets an Boolean attribute.Bset(java.lang.String key, char value)Sets an Character attribute.Bset(java.lang.String key, double value)Sets an Double attribute.Bset(java.lang.String key, float value)Sets an Float attribute.Bset(java.lang.String key, int value)Sets an Integer attribute.Bset(java.lang.String key, long value)Sets an Long attribute.Bset(java.lang.String key, java.lang.Object value)Sets an attribute, usingattribute.getClass()as attribute type.BsetProviderName(java.lang.String provider)Sets the provider.java.lang.StringtoString()
-
-
-
Method Detail
-
importContext
public B importContext(AbstractContext context, boolean overwriteDuplicates)
Apply all attributes on the given context.- Parameters:
context- the context to be applied, not null.overwriteDuplicates- flag, if existing entries should be overwritten.- Returns:
- this Builder, for chaining
-
importContext
public B importContext(AbstractContext context)
Apply all attributes on the given context, hereby existing entries are preserved.- Parameters:
context- the context to be applied, not null.- Returns:
- this Builder, for chaining
- See Also:
importContext(AbstractContext, boolean)
-
set
public B set(java.lang.String key, int value)
Sets an Integer attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.String key, boolean value)
Sets an Boolean attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.String key, long value)
Sets an Long attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.String key, float value)
Sets an Float attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.String key, double value)
Sets an Double attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.String key, char value)
Sets an Character attribute.- Parameters:
key- the key, non null.value- the value- Returns:
- the Builder, for chaining.
-
set
public B set(java.lang.Object value)
Sets an attribute, usingattribute.getClass()as attribute type andattribute.getClass().getName()as attribute name.- Parameters:
value- the attribute value, not null.- Returns:
- this Builder, for chaining
-
set
public B set(java.lang.String key, java.lang.Object value)
Sets an attribute, usingattribute.getClass()as attribute type.- Parameters:
value- the attribute value, not null.key- the attribute's key, notnull- Returns:
- this Builder, for chaining
-
set
public <T> B set(java.lang.Class<T> key, T value)
Sets an attribute, usingattribute.getClass()as attribute type.- Parameters:
value- the attribute value, not null.key- the attribute's key, notnull- Returns:
- this Builder, for chaining
-
setProviderName
public B setProviderName(java.lang.String provider)
Sets the provider.- Parameters:
provider- the provider, not null.- Returns:
- the Builder for chaining
-
removeAttributes
public B removeAttributes(java.lang.String... keys)
Removes an entry of a certain keys. This can be useful, when a context is initialized with another existing context, but only subset of the entries should be visible. For exampleremoveAttributes ("a", "b", "c")removes all attributes named 'a','b' and 'c'.- Parameters:
keys- the keys- Returns:
- this Builder, for chaining
-
build
public abstract C build()
Creates a newAbstractContextwith the data from this Builder instance.- Returns:
- a new
AbstractContext. nevernull.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-