/** * Returns a suitable hash code. * * @return a suitable hash code */ @Override public final int hashCode() { return getName().hashCode() ^ getClass().hashCode(); }
/** * Compares this name to another. * <p> * Instances are compared in alphabetical order based on the name, taking into account the implementation type. * * @param other the object to compare to * @return the comparison */ @Override public int compareTo(MarketDataName<?> other) { if (getClass() == other.getClass()) { return getName().compareTo(other.getName()); } return compareSlow(other); }
/** * Checks if this instance equals another. * <p> * Instances are compared based on the name and market data type. * * @param obj the object to compare to, null returns false * @return true if equal */ @Override public final boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == getClass()) { MarketDataName<?> other = (MarketDataName<?>) obj; return getName().equals(other.getName()); } return false; }
/** * Returns the name. * * @return the name */ @Override @ToString public final String toString() { return getName(); }
@Override public Set<String> tokens(CurrencyParameterSensitivity sensitivity) { return ImmutableSet.of( sensitivity.getCurrency().getCode().toLowerCase(Locale.ENGLISH), sensitivity.getMarketDataName().getName().toLowerCase(Locale.ENGLISH)); }
private boolean matchesToken(CurrencyParameterSensitivity sensitivity, String token) { return token.equalsIgnoreCase(sensitivity.getCurrency().getCode()) || token.equalsIgnoreCase(sensitivity.getMarketDataName().getName()); }
private Stream<String> tokensForSensitivity(CurrencyParameterSensitivity sensitivity) { return ImmutableSet.of( sensitivity.getCurrency().getCode(), sensitivity.getMarketDataName().getName()) .stream() .map(v -> v.toLowerCase(Locale.ENGLISH)); }
@Override public EvaluationResult evaluate( CurrencyParameterSensitivity sensitivity, CalculationFunctions functions, String firstToken, List<String> remainingTokens) { if (firstToken.equalsIgnoreCase(sensitivity.getCurrency().getCode()) || firstToken.equalsIgnoreCase(sensitivity.getMarketDataName().getName())) { return EvaluationResult.success(sensitivity, remainingTokens); } else { return invalidTokenFailure(sensitivity, firstToken); } }
.mapKeys((type, sens) -> Pair.of(sens.getMarketDataName().getName(), type)) .sortedKeys() .forEach((pair, paramSens) -> write(