Record Class CostComparability

java.lang.Object
java.lang.Record
com.eqixiac.equinix.design.cost.CostComparability
Record Components:
currency - the currency costs must be comparable in (commercial.currency)
costWeight - the weight the spec gives the cost objective
missingRates - the currencies whose rate to currency is missing, across all feasible designs
affected - keys of the feasible designs whose cost is unknown only for want of a rate
feasibleCount - how many feasible designs were examined
costWithdrawn - whether the rule removed cost from the ranking

public record CostComparability(String currency, double costWeight, SortedSet<String> missingRates, List<String> affected, int feasibleCount, boolean costWithdrawn) extends Record
Whether the cost of every feasible design can be compared in the spec's currency, and what the optimiser does when it cannot because an exchange rate is missing. With the built-in RateCardCostModel every line is converted (CurrencyConverters), so this is a safeguard for plug-in cost models.

The rule

"When cost carries weight and at least one feasible design\'s cost is unknown only because an exchange rate to the spec currency is missing, cost is withdrawn from the ranking for every design (so no design gains or loses for data the caller has not supplied), the result carries a finding naming the missing rates, and the affected designs are listed. The built-in RateCardCostModel converts every line (CurrencyConverters), so this applies only to a plug-in cost model that does not."

Why withdraw rather than rank: the weighted score gives an unknown objective no points, so a design priced in GBP (London) loses the whole cost weight to a design priced in USD (Istanbul) however cheap it really is. That is a ranking decided by which metros the price API happens to quote in USD, not by cost. Withdrawing cost for every design keeps the comparison fair until the caller supplies the rates; each design's priced lines are still reported, and the recommendation is stated to be blocked on cost.

  • Field Details

  • Constructor Details

    • CostComparability

      public CostComparability(String currency, double costWeight, SortedSet<String> missingRates, List<String> affected, int feasibleCount, boolean costWithdrawn)
      Copies the collections.
  • Method Details

    • assess

      public static CostComparability assess(Collection<MetroPortfolio> feasible, DesignContext context, double costWeight)
      Assesses a set of feasible designs.
      Parameters:
      feasible - every feasible portfolio
      context - the run's facts (spec and cost model)
      costWeight - the weight of the cost objective
      Returns:
      the assessment; costWithdrawn is true when the rule applies
    • missingRates

      public static SortedSet<String> missingRates(PortfolioCost cost, String currency)
      Parameters:
      cost - a priced portfolio
      currency - the comparison currency
      Returns:
      every line currency other than currency, sorted
    • unknownOnlyForExchangeRate

      public static boolean unknownOnlyForExchangeRate(PortfolioCost cost, String currency)
      Parameters:
      cost - a priced portfolio
      currency - the comparison currency
      Returns:
      true when every item is priced but some line is in another currency, so an exchange rate is the only thing standing between the design and a comparable total
    • incomplete

      public boolean incomplete()
      Returns:
      true when some feasible design's cost is unknown only for want of a rate
    • flags

      public boolean flags(MetroPortfolio portfolio)
      Parameters:
      portfolio - a design
      Returns:
      whether it is one of the designs whose cost is unknown only for want of a rate
    • headline

      public String headline()
      Returns:
      the BLOCKING finding's text, e.g. "cost comparison is incomplete: supply rates for EUR, GBP"
    • withdrawCost

      public static List<Objective> withdrawCost(List<Objective> objectives)
      The objectives with cost replaced by a withdrawn stand-in that reports every design's cost as unknown (its explanation keeps the design's own cost statement), so cost neither raises nor lowers any score.
      Parameters:
      objectives - the run's objectives
      Returns:
      the objectives to rank with
    • toMarkdown

      public String toMarkdown()
      Returns:
      a Markdown section stating the rule's outcome
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • currency

      public String currency()
      Returns the value of the currency record component.
      Returns:
      the value of the currency record component
    • costWeight

      public double costWeight()
      Returns the value of the costWeight record component.
      Returns:
      the value of the costWeight record component
    • missingRates

      public SortedSet<String> missingRates()
      Returns the value of the missingRates record component.
      Returns:
      the value of the missingRates record component
    • affected

      public List<String> affected()
      Returns the value of the affected record component.
      Returns:
      the value of the affected record component
    • feasibleCount

      public int feasibleCount()
      Returns the value of the feasibleCount record component.
      Returns:
      the value of the feasibleCount record component
    • costWithdrawn

      public boolean costWithdrawn()
      Returns the value of the costWithdrawn record component.
      Returns:
      the value of the costWithdrawn record component