Class CurrencyConverters

java.lang.Object
com.eqixiac.equinix.design.cost.CurrencyConverters

public final class CurrencyConverters extends Object
Builds the currency converter every cost model uses, and reports what it did.

Precedence

  1. rates pinned in the spec (commercial.exchangeRates; in the fingerprint; no widening unless the spec states a band);
  2. a converter the caller or a DesignPlugin supplies;
  3. the default: live ECB reference rates via Frankfurter (FrankfurterExchangeRates, one call per run, ±2.0%);
  4. the fallback: the bundled table (BundledExchangeRates, ±5.0%).

Air-gapped use: bundledOnly(), or the system property "equinix.design.fx.offline"=true, removes step 3 everywhere. A currency missing from every source leaves the line unpriced with that reason.

  • Field Details

    • OFFLINE_PROPERTY

      public static final String OFFLINE_PROPERTY
      System property that disables the live FX source when true.
      See Also:
  • Method Details

    • bundledOnly

      public static CurrencyConverter bundledOnly()
      Returns:
      the bundled reference table alone (no network)
    • none

      public static CurrencyConverter none()
      Returns:
      a converter with no rates: every conversion is unpriced (for tests and strict runs)
    • standard

      public static CurrencyConverter standard(String target)
      The default: live ECB rates for target (unless "equinix.design.fx.offline" is set) then the bundled table.
      Parameters:
      target - the comparison currency
      Returns:
      the converter
    • forSpec

      public static CurrencyConverters.Chain forSpec(DesignSpec spec, CurrencyConverter supplied)
      The converter for a spec: pinned rates, then supplied, then standard(String).
      Parameters:
      spec - the spec (currency and pinned rates)
      supplied - a caller or plug-in converter, or null
      Returns:
      the converter
    • forTerms

      public static CurrencyConverters.Chain forTerms(CommercialTerms terms, CurrencyConverter supplied, CurrencyConverter fallbacks)
      Parameters:
      terms - the commercial terms (currency and pinned rates)
      supplied - a caller or plug-in converter, or null
      fallbacks - what to use after supplied; null for standard(String)
      Returns:
      the converter
    • chain

      public static CurrencyConverters.Chain chain(CurrencyConverter... converters)
      Parameters:
      converters - in precedence order
      Returns:
      a converter that answers from the first that has the pair
    • convert

      public static Optional<CostLine> convert(CostLine line, String target, CurrencyConverter converter)
      Restates one cost line in target: the line keeps its original amounts, currency and the rate used (with the rate's kind, source and date) in CostLine.conversion(), its note states the rate, and its range is widened by the rate's band. A line converted at a bundled reference rate becomes PriceSource.ESTIMATE. This is the one conversion every cost figure in the design package goes through (the optimiser's cost model, the wizard's plan pricing and the estate analysis).
      Parameters:
      line - the line as priced
      target - the ISO 4217 code to restate it in
      converter - the rate source
      Returns:
      the line in target (the line itself when already in it), or empty when no source has the rate
    • advisory

      public static Optional<String> advisory(PortfolioCost cost)
      A non-blocking advisory, e.g. "3 of 12 line(s) converted to USD: GBP at ECB reference rate via Frankfurter, 2026-11-11; SGD at bundled reference table, as of 2026-11-11".
      Parameters:
      cost - a priced portfolio
      Returns:
      the advisory, empty when nothing was converted
    • usedRates

      public static Optional<CommercialTerms.ExchangeRates> usedRates(String target, List<PortfolioCost> costs)
      The exact rates the given costs used, as pinnable spec rates, so a run can be reproduced.
      Parameters:
      target - the comparison currency
      costs - priced portfolios
      Returns:
      the rates, or empty when nothing was converted
    • pinUsedRates

      public static DesignSpec pinUsedRates(DesignSpec spec, List<PortfolioCost> costs)
      The spec with the rates the given costs used pinned in commercial.exchangeRates (rates already pinned are kept and take precedence), so re-running it reproduces the result.
      Parameters:
      spec - the spec that was run
      costs - the costs that run produced
      Returns:
      the spec with pinned rates (unchanged when nothing was converted)