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.Object
This 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
, ExchangeRateProvider
and .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 C
build()
Creates a newAbstractContext
with the data from this Builder instance.B
importContext(AbstractContext context)
Apply all attributes on the given context, hereby existing entries are preserved.B
importContext(AbstractContext context, boolean overwriteDuplicates)
Apply all attributes on the given context.B
removeAttributes(java.lang.String... keys)
Removes an entry of a certain keys.<T> B
set(java.lang.Class<T> key, T value)
Sets an attribute, usingattribute.getClass()
as attribute type.B
set(java.lang.Object value)
Sets an attribute, usingattribute.getClass()
as attribute type andattribute.getClass().getName()
as attribute name.B
set(java.lang.String key, boolean value)
Sets an Boolean attribute.B
set(java.lang.String key, char value)
Sets an Character attribute.B
set(java.lang.String key, double value)
Sets an Double attribute.B
set(java.lang.String key, float value)
Sets an Float attribute.B
set(java.lang.String key, int value)
Sets an Integer attribute.B
set(java.lang.String key, long value)
Sets an Long attribute.B
set(java.lang.String key, java.lang.Object value)
Sets an attribute, usingattribute.getClass()
as attribute type.B
setProviderName(java.lang.String provider)
Sets the provider.java.lang.String
toString()
-
Constructor Details
-
AbstractContextBuilder
public AbstractContextBuilder()
-
-
Method Details
-
importContext
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
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
Sets an Integer attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
Sets an Boolean attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
Sets an Long attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
Sets an Float attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
Sets an Double attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
Sets an Character attribute.- Parameters:
key
- the key, non null.value
- the value- Returns:
- the Builder, for chaining.
-
set
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
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
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
Sets the provider.- Parameters:
provider
- the provider, not null.- Returns:
- the Builder for chaining
-
removeAttributes
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
Creates a newAbstractContext
with the data from this Builder instance.- Returns:
- a new
AbstractContext
. nevernull
.
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-