Class CurrencyConverters
java.lang.Object
com.eqixiac.equinix.design.cost.CurrencyConverters
Builds the currency converter every cost model uses, and reports what it did.
Precedence
- rates pinned in the spec (
commercial.exchangeRates; in the fingerprint; no widening unless the spec states a band); - a converter the caller or a
DesignPluginsupplies; - the default: live ECB reference rates via Frankfurter (
FrankfurterExchangeRates, one call per run, ±2.0%); - 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFirst-answer-wins composition that can report fallbacks. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property that disables the live FX source whentrue. -
Method Summary
Modifier and TypeMethodDescriptionadvisory(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".static CurrencyConverterstatic CurrencyConverters.Chainchain(CurrencyConverter... converters) convert(CostLine line, String target, CurrencyConverter converter) Restates one cost line intarget: the line keeps its original amounts, currency and the rate used (with the rate's kind, source and date) inCostLine.conversion(), its note states the rate, and its range is widened by the rate's band.static CurrencyConverters.ChainforSpec(DesignSpec spec, CurrencyConverter supplied) The converter for a spec: pinned rates, thensupplied, thenstandard(String).static CurrencyConverters.ChainforTerms(CommercialTerms terms, CurrencyConverter supplied, CurrencyConverter fallbacks) static CurrencyConverternone()static DesignSpecpinUsedRates(DesignSpec spec, List<PortfolioCost> costs) The spec with the rates the given costs used pinned incommercial.exchangeRates(rates already pinned are kept and take precedence), so re-running it reproduces the result.static CurrencyConverterThe default: live ECB rates fortarget(unless "equinix.design.fx.offline" is set) then the bundled table.usedRates(String target, List<PortfolioCost> costs) The exact rates the given costs used, as pinnable spec rates, so a run can be reproduced.
-
Field Details
-
OFFLINE_PROPERTY
System property that disables the live FX source whentrue.- See Also:
-
-
Method Details
-
bundledOnly
- Returns:
- the bundled reference table alone (no network)
-
none
- Returns:
- a converter with no rates: every conversion is unpriced (for tests and strict runs)
-
standard
The default: live ECB rates fortarget(unless "equinix.design.fx.offline" is set) then the bundled table.- Parameters:
target- the comparison currency- Returns:
- the converter
-
forSpec
The converter for a spec: pinned rates, thensupplied, thenstandard(String).- Parameters:
spec- the spec (currency and pinned rates)supplied- a caller or plug-in converter, ornull- 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, ornullfallbacks- what to use aftersupplied;nullforstandard(String)- Returns:
- the converter
-
chain
- Parameters:
converters- in precedence order- Returns:
- a converter that answers from the first that has the pair
-
convert
Restates one cost line intarget: the line keeps its original amounts, currency and the rate used (with the rate's kind, source and date) inCostLine.conversion(), its note states the rate, and its range is widened by the rate's band. A line converted at a bundled reference rate becomesPriceSource.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 pricedtarget- the ISO 4217 code to restate it inconverter- the rate source- Returns:
- the line in
target(the line itself when already in it), or empty when no source has the rate
-
advisory
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 currencycosts- priced portfolios- Returns:
- the rates, or empty when nothing was converted
-
pinUsedRates
The spec with the rates the given costs used pinned incommercial.exchangeRates(rates already pinned are kept and take precedence), so re-running it reproduces the result.- Parameters:
spec- the spec that was runcosts- the costs that run produced- Returns:
- the spec with pinned rates (unchanged when nothing was converted)
-