Top Description Fields Constructors Methods
javax.money

public abstract Class AbstractContext

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Known Direct Subclasses
javax.money.AbstractQuery, javax.money.CurrencyContext, javax.money.MonetaryContext, javax.money.RoundingContext, javax.money.convert.ConversionContext, javax.money.convert.ProviderContext, javax.money.format.AmountFormatContext
Annotations
@SuppressWarnings:unchecked
Imports
java.io.Serializable, java.util.HashMap, .Map, .Objects, .Set, java.util.stream.Collectors

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.

Field Summary

Modifier and TypeField and Description
pack-priv final Map<String, Object>
data

The data map containing all values.

protected static final String
KEY_PROVIDER

Key for storing the target providers to be queried

private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractContext(AbstractContextBuilder<?, ?>
the Builder.
builder
)

Private constructor, used by AbstractContextBuilder.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public <T> T

Returns:

the attribute value, or null.
get
(String
the attribute's key, not null
key
,
Class<T>
the attribute's type, not null
type
)

Access an attribute.

public <T> T

Returns:

the type attribute value, or null.
get
(Class<T>
the type, not null
type
)

Access an attribute, hereby using the class name as key.

public Boolean

Returns:

the value, or null.
getBoolean
(String
the attribute's key, not null.
key
)

Access a Boolean attribute.

public Double

Returns:

the value, or null.
getDouble
(String
the attribute's key, not null.
key
)

Access a Double attribute.

public Float

Returns:

the value, or null.
getFloat
(String
the attribute's key, not null.
key
)

Access a Float attribute.

public Integer

Returns:

the value, or null.
getInt
(String
the attribute's key, not null.
key
)

Access an Integer attribute.

public Set<String>

Returns:

all present keys of attributes being assignable to the type, never null.
getKeys
(Class<?>
The attribute type, not null.
type
)

Get the present keys of all entries with a given type, checking hereby if assignable.

public Long

Returns:

the value, or null.
getLong
(String
the attribute's key, not null.
key
)

Access a Long attribute.

public String

Returns:

the provider name, or null.
getProviderName
()

Get the provider name of this context.

public String

Returns:

the value, or null.
getText
(String
the attribute's key, not null.
key
)

Access a String attribute.

public Class<?>

Returns:

the current attribute type, or null, if no such attribute exists.
getType
(String
the entry's key, not null
key
)

Get the current attribute type.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true, if no attributes are set.
isEmpty
()

Checks if the current instance has no attributes set.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

databack to summary
pack-priv final Map<String, Object> data

The data map containing all values.

KEY_PROVIDERback to summary
protected static final String KEY_PROVIDER

Key for storing the target providers to be queried

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AbstractContextback to summary
protected AbstractContext(AbstractContextBuilder<?, ?> builder)

Private constructor, used by AbstractContextBuilder.

Parameters
builder:AbstractContextBuilder<?, ?>

the Builder.

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public <T> T get(String key, Class<T> type)

Access an attribute.

Parameters
key:String

the attribute's key, not null

type:Class<T>

the attribute's type, not null

Returns:T

the attribute value, or null.

getback to summary
public <T> T get(Class<T> type)

Access an attribute, hereby using the class name as key.

Parameters
type:Class<T>

the type, not null

Returns:T

the type attribute value, or null.

getBooleanback to summary
public Boolean getBoolean(String key)

Access a Boolean attribute.

Parameters
key:String

the attribute's key, not null.

Returns:Boolean

the value, or null.

getDoubleback to summary
public Double getDouble(String key)

Access a Double attribute.

Parameters
key:String

the attribute's key, not null.

Returns:Double

the value, or null.

getFloatback to summary
public Float getFloat(String key)

Access a Float attribute.

Parameters
key:String

the attribute's key, not null.

Returns:Float

the value, or null.

getIntback to summary
public Integer getInt(String key)

Access an Integer attribute.

Parameters
key:String

the attribute's key, not null.

Returns:Integer

the value, or null.

getKeysback to summary
public Set<String> getKeys(Class<?> type)

Get the present keys of all entries with a given type, checking hereby if assignable.

Parameters
type:Class<?>

The attribute type, not null.

Returns:Set<String>

all present keys of attributes being assignable to the type, never null.

getLongback to summary
public Long getLong(String key)

Access a Long attribute.

Parameters
key:String

the attribute's key, not null.

Returns:Long

the value, or null.

getProviderNameback to summary
public String getProviderName()

Get the provider name of this context.

Returns:String

the provider name, or null.

getTextback to summary
public String getText(String key)

Access a String attribute.

Parameters
key:String

the attribute's key, not null.

Returns:String

the value, or null.

getTypeback to summary
public Class<?> getType(String key)

Get the current attribute type.

Parameters
key:String

the entry's key, not null

Returns:Class<?>

the current attribute type, or null, if no such attribute exists.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Checks if the current instance has no attributes set. This is often the cases, when used in default cases.

Returns:boolean

true, if no attributes are set.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override