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 new AbstractContext 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, using attribute.getClass() as attribute type.
    B set​(java.lang.Object value)
    Sets an attribute, using attribute.getClass() as attribute type and attribute.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, using attribute.getClass() as attribute type.
    B setProviderName​(java.lang.String provider)
    Sets the provider.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • 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, using attribute.getClass() as attribute type and attribute.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, using attribute.getClass() as attribute type.
      Parameters:
      value - the attribute value, not null.
      key - the attribute's key, not null
      Returns:
      this Builder, for chaining
    • set

      public <T> B set​(java.lang.Class<T> key, T value)
      Sets an attribute, using attribute.getClass() as attribute type.
      Parameters:
      value - the attribute value, not null.
      key - the attribute's key, not null
      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 example removeAttributes ("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 new AbstractContext with the data from this Builder instance.
      Returns:
      a new AbstractContext. never null.
    • toString

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