### Question:
BeanTokenEvaluator extends TokenEvaluator<Bean> { @Override public Set<String> tokens(Bean bean) { if (bean.propertyNames().size() == 1) { String singlePropertyName = Iterables.getOnlyElement(bean.propertyNames()); Object propertyValue = bean.property(singlePropertyName).get(); Set<String> valueTokens = ValuePathEvaluator.tokens(propertyValue); return ImmutableSet.<String>builder() .add(singlePropertyName) .addAll(valueTokens) .build(); } else { return bean.propertyNames(); } }  @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 tokens() { Bean bean = bean(); BeanTokenEvaluator evaluator = new BeanTokenEvaluator(); Set<String> tokens = evaluator.tokens(bean); ImmutableSet<String> expectedTokens = ImmutableSet.of( "buySell", "currency", "notional", "startDate", "endDate", "businessDayAdjustment", "paymentDate", "fixedRate", "index", "indexInterpolated", "fixingDateOffset", "dayCount", "discounting"); assertThat(tokens).isEqualTo(expectedTokens); }
@Test public void tokensSingleProperty() { 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(); Set<String> tokens = evaluator.tokens(amounts); assertThat(tokens).isEqualTo(ImmutableSet.of("amounts", "0", "aud", "pay", "fixed")); }