Class SavingsCalculator.Builder

java.lang.Object
com.eqixiac.equinix.design.value.savings.SavingsCalculator.Builder
Enclosing class:
SavingsCalculator

public static final class SavingsCalculator.Builder extends Object
Fluent configuration for a savings estimate, terminated by calculate(). Setters validate eagerly (fail-fast IllegalArgumentExceptions), so a mistake surfaces at the call site rather than as a wrong number later.

Defaults: 1000 Mbps bandwidth, EVPL_VC connection type, Term.MONTH_12, egress volume 0 GB, no Cloud Router, and the standard layered rate-card chain (live Equinix pricing, then bundled reference figures). Cloud-to-cloud defaults: no peer cloud, path tier 1, AWS free tier not applied, reverse volume equal to the forward volume.

Constraints that span two levers are checked at calculate(), because levers may be set in any order: toRegion, pathTier, reverseEgress and useAwsFreeTier(true) each require toCloud; toCloud requires fromCloud and must differ from it; useAwsFreeTier(true) requires AWS as one of the two clouds. Each violation is an IllegalArgumentException naming the lever.

  • Method Details

    • egress

      public SavingsCalculator.Builder egress(double amount, DataUnit unit)
      Sets the monthly cloud data-egress volume the estimate is built around (default 0).
      Parameters:
      amount - the volume in units per month
      unit - the unit the amount is expressed in (decimal/SI conversions)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the amount is negative or not finite, or the unit is null
    • egressGigabytes

      public SavingsCalculator.Builder egressGigabytes(double gigabytes)
      Shorthand for egress(gigabytes, DataUnit.GIGABYTE).
    • egressTerabytes

      public SavingsCalculator.Builder egressTerabytes(double terabytes)
      Shorthand for egress(terabytes, DataUnit.TERABYTE) (1 TB = 1000 GB).
    • fromCloud

      public SavingsCalculator.Builder fromCloud(CloudProviderType provider)
      Sets the cloud provider the egress leaves - the provider whose internet and private egress rates are compared.
      Parameters:
      provider - the cloud provider
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the provider is null, or equals a toCloud(...) already set
    • toCloud

      public SavingsCalculator.Builder toCloud(CloudProviderType provider)
      Declares the peer cloud. The estimate then carries a MulticloudPathComparison (internet, Equinix and native paths, both directions) and a break-even sustained rate. Beta.
      Parameters:
      provider - the cloud at the other end; must differ from fromCloud(...)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the provider is null, or equals a fromCloud(...) already set (the same check runs again at calculate())
    • toRegion

      public SavingsCalculator.Builder toRegion(String region)
      Sets the peer cloud's region in its own notation (e.g. "us-east4"). Optional. The bundled reference data uses it to select Google's transport location; with no region it prices a Google Cloud side at the North America location and says so.
      Parameters:
      region - the peer region identifier (may be null)
      Returns:
      this builder for method chaining
    • pathTier

      public SavingsCalculator.Builder pathTier(int pathTier)
      Sets the AWS connectivity-scope tier of the native link: 1 local (default), 2 regional, 3 continental, 4 long-haul, 5 maximum scope. An input, never derived: AWS publishes no path-to-tier table. Providers without a tier concept ignore it.
      Parameters:
      pathTier - the tier, 1-5
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if outside 1-5
    • useAwsFreeTier

      public SavingsCalculator.Builder useAwsFreeTier(boolean useAwsFreeTier)
      Opts in to the AWS free tier for the native link (one free tier-1 500 Mbps interconnect per AWS Region per generally-available provider). Off by default and never inferred. When set but the request is ineligible, the listed rate applies and the comparison's notes say why.
      Parameters:
      useAwsFreeTier - true to apply the free tier where eligible
      Returns:
      this builder for method chaining
    • reverseEgress

      public SavingsCalculator.Builder reverseEgress(double amount, DataUnit unit)
      Sets the monthly volume flowing from the peer cloud back to fromCloud. When not set, the cloud-to-cloud comparison assumes it equals the forward volume and says so in its notes.
      Parameters:
      amount - the volume in units per month
      unit - the unit the amount is expressed in (decimal/SI conversions)
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the amount is negative or not finite, or the unit is null
    • inRegion

      public SavingsCalculator.Builder inRegion(String region)
      Sets the provider region the egress originates in, in the provider's own region notation (e.g. "us-east-1", "westeurope"). Optional: region-agnostic rate cards ignore it, but the provider-API adapters need it.
      Parameters:
      region - the provider region identifier (may be null for provider-wide rates)
      Returns:
      this builder for method chaining
    • viaMetro

      public SavingsCalculator.Builder viaMetro(MetroCode metro)
      Sets the Equinix metro the interconnect lands in, used for metro-sensitive rate lookups. Omit the call entirely for a metro-agnostic estimate.
      Parameters:
      metro - the Equinix metro
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the metro is null (omit the call instead)
    • bandwidthMbps

      public SavingsCalculator.Builder bandwidthMbps(int bandwidthMbps)
      Sets the interconnect bandwidth in Mbps (default 1000), which drives the Fabric connection price the egress saving is netted against.
      Parameters:
      bandwidthMbps - the bandwidth in Mbps
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if not positive
    • connectionType

      public SavingsCalculator.Builder connectionType(ConnectionType connectionType)
      Sets the Fabric connection type priced for the interconnect (default EVPL_VC).
      Parameters:
      connectionType - the connection type
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if null
    • includeCloudRouter

      public SavingsCalculator.Builder includeCloudRouter(String packageCode)
      Adds a Fabric Cloud Router of the given package to the interconnect cost (none is included by default). If the rate card cannot price the package - or prices it in a different currency from the connection - the interconnect figures stay partial (connection only), isEquinixPriced() flips false, and the estimate's disclaimer names the excluded router; the router is never silently dropped from an estimate reported as complete.
      Parameters:
      packageCode - the router package code (e.g. "STANDARD")
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if the package code is null or blank
    • term

      public SavingsCalculator.Builder term(Term term)
      Sets the commitment term used for the term-aware rate lookups (default Term.MONTH_12).
      Parameters:
      term - the commitment term
      Returns:
      this builder for method chaining
      Throws:
      IllegalArgumentException - if null
    • currency

      public SavingsCalculator.Builder currency(String currency)
      Sets the currency every figure is compared in (default USD). Figures quoted in another currency are converted: rates pinned with exchangeRates, then currencyConverter, then live ECB reference rates (one call), then the SDK's bundled table. Only a currency no source covers is unpriced.
      Parameters:
      currency - ISO 4217 code
      Returns:
      this builder for method chaining
    • exchangeRates

      Pins exchange rates to currency(String); they take precedence over every other source.
      Parameters:
      rates - the rates, or null for none
      Returns:
      this builder for method chaining
    • currencyConverter

      public SavingsCalculator.Builder currencyConverter(CurrencyConverter converter)
      Supplies a converter (for example a live FX feed) ranked below pinned rates and above the defaults.
      Parameters:
      converter - the converter, or null for none
      Returns:
      this builder for method chaining
    • defaultRates

      public SavingsCalculator.Builder defaultRates(CurrencyConverter defaults)
      Replaces the default rate sources (live ECB rates, then the bundled table), for example with CurrencyConverters.bundledOnly() for an offline run.
      Parameters:
      defaults - the fallback converter, or null for the defaults
      Returns:
      this builder for method chaining
    • rateCard

      public SavingsCalculator.Builder rateCard(RateCard rateCard)
      Sets the rate card that prices both egress and Equinix interconnect resources. When omitted, the standard layered chain (RateCard.standardChain(fabric)) applies: live Equinix Fabric pricing first, then the bundled ReferenceRateCard, which also supplies indicative cloud-egress rates - so egress savings are computed out of the box with no card supplied. A supplied card replaces that chain entirely (it is not layered over the defaults); to keep the defaults as a fallback behind your own figures, pass RateCard.layered(customCard, RateCard.standardChain(fabric)).
      Parameters:
      rateCard - the rate card to price with, or null to use the standard chain
      Returns:
      this builder for method chaining
    • calculate

      public SavingsEstimate calculate()
      Runs the calculation.
      Returns:
      the savings estimate
      Throws:
      IllegalArgumentException - if levers conflict: toRegion, pathTier, reverseEgress or useAwsFreeTier(true) without toCloud; toCloud without, or equal to, fromCloud; or useAwsFreeTier(true) when neither cloud is AWS