class CurrencyParameterSensitivitiesTokenEvaluator extends TokenEvaluator<CurrencyParameterSensitivities> {

  @Override
  public EvaluationResult evaluate(
      CurrencyParameterSensitivities sensitivities,
      CalculationFunctions functions,
      String firstToken,
      List<String> remainingTokens) {

    List<CurrencyParameterSensitivity> matchingSensitivities = sensitivities.getSensitivities().stream()
        .filter(sensitivity -> matchesToken(sensitivity, firstToken))
        .collect(toImmutableList());

    switch (matchingSensitivities.size()) {
      case 0:
        return invalidTokenFailure(sensitivities, firstToken);
      case 1:
        return EvaluationResult.success(matchingSensitivities.get(0), remainingTokens);

      default:
        return EvaluationResult.success(CurrencyParameterSensitivities.of(matchingSensitivities), remainingTokens);
    }
  }

}