java.lang.Object
javax.money.AbstractContext
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractQuery,AmountFormatContext,ConversionContext,CurrencyContext,MonetaryContext,ProviderContext,RoundingContext
Represents a general context of data targeting an item of type
Q. Contexts are used to add arbitrary
data that cannot be be mapped in a standard way to the money API, e.g. use case or customer specific
extensions or specialities.Superclasses of this class must be final, immutable, serializable and thread-safe.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe data map containing all values.protected static final StringKey for storing the target providers to be queriedprivate static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractContext(AbstractContextBuilder<?, ?> builder) Private constructor, used byAbstractContextBuilder. -
Method Summary
Modifier and TypeMethodDescriptionboolean<T> TAccess an attribute, hereby using the class name as key.<T> TAccess an attribute.getBoolean(String key) Access a Boolean attribute.Access a Double attribute.Access a Float attribute.Access an Integer attribute.Get the present keys of all entries with a given type, checking hereby if assignable.Access a Long attribute.Get the provider name of this context.Access a String attribute.Class<?> Get the current attribute type.inthashCode()booleanisEmpty()Checks if the current instance has no attributes set.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
KEY_PROVIDER
Key for storing the target providers to be queried- See Also:
-
data
The data map containing all values.
-
-
Constructor Details
-
AbstractContext
Private constructor, used byAbstractContextBuilder.- Parameters:
builder- the Builder.
-
-
Method Details
-
getKeys
Get the present keys of all entries with a given type, checking hereby if assignable.- Parameters:
type- The attribute type, not null.- Returns:
- all present keys of attributes being assignable to the type, never null.
-
getType
Get the current attribute type.- Parameters:
key- the entry's key, not null- Returns:
- the current attribute type, or null, if no such attribute exists.
-
get
Access an attribute.- Parameters:
key- the attribute's key, notnulltype- the attribute's type, notnull- Returns:
- the attribute value, or
null.
-
get
Access an attribute, hereby using the class name as key.- Parameters:
type- the type, notnull- Returns:
- the type attribute value, or
null.
-
getLong
Access a Long attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getFloat
Access a Float attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getInt
Access an Integer attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getBoolean
Access a Boolean attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getDouble
Access a Double attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getText
Access a String attribute.- Parameters:
key- the attribute's key, not null.- Returns:
- the value, or null.
-
getProviderName
Get the provider name of this context.- Returns:
- the provider name, or null.
-
isEmpty
public boolean isEmpty()Checks if the current instance has no attributes set. This is often the cases, when used in default cases.- Returns:
- true, if no attributes are set.
-
hashCode
public int hashCode() -
equals
-
toString
-