### Question:
BeanTokenEvaluator extends TokenEvaluator<Bean> { @Override public EvaluationResult evaluate( Bean bean, CalculationFunctions functions, String firstToken, List<String> remainingTokens) { Optional<String> propertyName = bean.propertyNames().stream() .filter(p -> p.equalsIgnoreCase(firstToken)) .findFirst(); if (propertyName.isPresent()) { Object propertyValue = bean.property(propertyName.get()).get(); return propertyValue != null ? EvaluationResult.success(propertyValue, remainingTokens) : EvaluationResult.failure("No value available for property '{}'", firstToken); } if (bean.propertyNames().size() == 1) { String singlePropertyName = Iterables.getOnlyElement(bean.propertyNames()); Object propertyValue = bean.property(singlePropertyName).get(); List<String> tokens = ImmutableList.<String>builder().add(firstToken).addAll(remainingTokens).build(); return propertyValue != null ? EvaluationResult.success(propertyValue, tokens) : EvaluationResult.failure("No value available for property '{}'", firstToken); } return invalidTokenFailure(bean, firstToken); }  @Override Class<Bean> getTargetType(); @Override Set<String> tokens(Bean bean); @Override EvaluationResult evaluate(
      Bean bean,
      CalculationFunctions functions,
      String firstToken,
      List<String> remainingTokens);  }### Answer:
@Test public void evaluate() { Bean bean = bean(); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); EvaluationResult notional1 = evaluator.evaluate(bean, FUNCTIONS, "notional", ImmutableList.of()); assertThat(notional1.getResult()).hasValue(1_000_000d); EvaluationResult notional2 = evaluator.evaluate(bean, FUNCTIONS, "Notional", ImmutableList.of()); assertThat(notional2.getResult()).hasValue(1_000_000d); }
@Test public void evaluateSingleProperty() { SwapLegAmount amount = SwapLegAmount.builder() .amount(CurrencyAmount.of(Currency.AUD, 7)) .payReceive(PayReceive.PAY) .type(SwapLegType.FIXED) .currency(Currency.AUD) .build(); LegAmounts amounts = LegAmounts.of(amount); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); EvaluationResult result1 = evaluator.evaluate(amounts, FUNCTIONS, "amounts", ImmutableList.of("foo", "bar")); assertThat(result1.getResult()).hasValue(ImmutableList.of(amount)); assertThat(result1.getRemainingTokens()).isEqualTo(ImmutableList.of("foo", "bar")); EvaluationResult result2 = evaluator.evaluate(amounts, FUNCTIONS, "baz", ImmutableList.of("foo", "bar")); assertThat(result2.getResult()).hasValue(ImmutableList.of(amount)); assertThat(result2.getRemainingTokens()).isEqualTo(ImmutableList.of("baz", "foo", "bar")); }