Class ExchangeRateBuilder

java.lang.Object
org.javamoney.moneta.convert.ExchangeRateBuilder

public class ExchangeRateBuilder
extends Object
Builder for creating new instances of ExchangeRate. Note that instances of this class are not thread-safe.
Author:
Anatole Tresch, Werner Keil
  • Constructor Details

  • Method Details

    • setBase

      public ExchangeRateBuilder setBase​(javax.money.CurrencyUnit base)
      Sets the base CurrencyUnit
      Parameters:
      base - to base (source) CurrencyUnit to be applied
      Returns:
      the builder instance
    • setTerm

      public ExchangeRateBuilder setTerm​(javax.money.CurrencyUnit term)
      Sets the terminating (target) CurrencyUnit
      Parameters:
      term - to terminating CurrencyUnit to be applied
      Returns:
      the builder instance
    • setRateChain

      public ExchangeRateBuilder setRateChain​(javax.money.convert.ExchangeRate... exchangeRates)
      Sets the ExchangeRate chain.
      Parameters:
      exchangeRates - the ExchangeRate chain to be applied
      Returns:
      the builder instance
    • setRateChain

      public ExchangeRateBuilder setRateChain​(List<javax.money.convert.ExchangeRate> exchangeRates)
      Sets the ExchangeRate chain.
      Parameters:
      exchangeRates - the ExchangeRate chain to be applied
      Returns:
      the builder instance
    • setFactor

      public ExchangeRateBuilder setFactor​(javax.money.NumberValue factor)
      Sets the conversion factor, as the factor base * factor = target.
      Parameters:
      factor - the factor.
      Returns:
      The builder instance.
    • setContext

      public ExchangeRateBuilder setContext​(javax.money.convert.ConversionContext conversionContext)
      Sets the provider to be applied.
      Parameters:
      conversionContext - the ConversionContext, not null.
      Returns:
      The builder.
    • build

      public javax.money.convert.ExchangeRate build()
      Builds a new instance of ExchangeRate.
      Returns:
      a new instance of ExchangeRate.
      Throws:
      IllegalArgumentException - if the rate could not be built.
    • setRate

      public ExchangeRateBuilder setRate​(javax.money.convert.ExchangeRate rate)
      Initialize the ExchangeRateBuilder with an ExchangeRate. This is useful for creating a new rate, reusing some properties from an existing one.
      Parameters:
      rate - the base rate
      Returns:
      the Builder, for chaining.
    • toString

      public String toString()
      Overrides:
      toString in class Object