Module java.money
Package javax.money

Class AbstractContext

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    AbstractQuery, AmountFormatContext, ConversionContext, CurrencyContext, MonetaryContext, ProviderContext, RoundingContext

    public abstract class AbstractContext
    extends java.lang.Object
    implements java.io.Serializable
    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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String KEY_PROVIDER
      Key for storing the target providers to be queried
    • Method Summary

      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      <T> T get​(java.lang.Class<T> type)
      Access an attribute, hereby using the class name as key.
      <T> T get​(java.lang.String key, java.lang.Class<T> type)
      Access an attribute.
      java.lang.Boolean getBoolean​(java.lang.String key)
      Access a Boolean attribute.
      java.lang.Double getDouble​(java.lang.String key)
      Access a Double attribute.
      java.lang.Float getFloat​(java.lang.String key)
      Access a Float attribute.
      java.lang.Integer getInt​(java.lang.String key)
      Access an Integer attribute.
      java.util.Set<java.lang.String> getKeys​(java.lang.Class<?> type)
      Get the present keys of all entries with a given type, checking hereby if assignable.
      java.lang.Long getLong​(java.lang.String key)
      Access a Long attribute.
      java.lang.String getProviderName()
      Get the provider name of this context.
      java.lang.String getText​(java.lang.String key)
      Access a String attribute.
      java.lang.Class<?> getType​(java.lang.String key)
      Get the current attribute type.
      int hashCode()  
      boolean isEmpty()
      Checks if the current instance has no attributes set.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • KEY_PROVIDER

        protected static final java.lang.String KEY_PROVIDER
        Key for storing the target providers to be queried
        See Also:
        Constant Field Values
    • Method Detail

      • getKeys

        public java.util.Set<java.lang.String> getKeys​(java.lang.Class<?> type)
        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

        public java.lang.Class<?> getType​(java.lang.String key)
        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

        public <T> T get​(java.lang.String key,
                         java.lang.Class<T> type)
        Access an attribute.
        Parameters:
        type - the attribute's type, not null
        key - the attribute's key, not null
        Returns:
        the attribute value, or null.
      • get

        public <T> T get​(java.lang.Class<T> type)
        Access an attribute, hereby using the class name as key.
        Parameters:
        type - the type, not null
        Returns:
        the type attribute value, or null.
      • getLong

        public java.lang.Long getLong​(java.lang.String key)
        Access a Long attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getFloat

        public java.lang.Float getFloat​(java.lang.String key)
        Access a Float attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getInt

        public java.lang.Integer getInt​(java.lang.String key)
        Access an Integer attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getBoolean

        public java.lang.Boolean getBoolean​(java.lang.String key)
        Access a Boolean attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getDouble

        public java.lang.Double getDouble​(java.lang.String key)
        Access a Double attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getText

        public java.lang.String getText​(java.lang.String key)
        Access a String attribute.
        Parameters:
        key - the attribute's key, not null.
        Returns:
        the value, or null.
      • getProviderName

        public java.lang.String 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()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object