예제 #1
0
 @Test
 public void specificSideEffect() {
   SomeComposite some = transientBuilderFactory.newTransient(SomeComposite.class);
   Property<Integer> count = some.count();
   assertThat("count is zero", count.get(), equalTo(0));
   some.doStuff();
   assertThat("count is not zero", count.get(), not(equalTo(0)));
 }
  private void refreshResult() {
    Double f1 = factor1Value == null ? factor1.get() : factor1Value;
    Double f2 = factor2Value == null ? factor2.get() : factor2Value;

    Double resultValue = (f1 == null ? 0 : f1) * (f2 == null ? 0 : f2);
    if (roundUp) {
      resultValue = MathUtil.round(resultValue);
    }
    site.setFieldValue(
        result.qualifiedName().name(),
        NumberFormatter.getFormatter(fractionDigits).format(resultValue));
  }
 @Override
 public void fieldChange(FormFieldEvent ev) {
   if (ev.getEventCode() != IFormFieldListener.VALUE_CHANGE) {
     return;
   }
   String fieldName = ev.getFieldName();
   if (fieldName.equals(factor1.qualifiedName().name())) {
     Double newValue = (Double) ev.getNewValue(); // explizitely deleting this
     // value
     if (newValue == null) {
       newValue = Double.valueOf(0.0d);
     }
     factor1Value = newValue;
     refreshResult();
   } else if (fieldName.equals(factor2.qualifiedName().name())) {
     Double newValue = (Double) ev.getNewValue(); // explizitely deleting this
     // value
     if (newValue == null) {
       newValue = Double.valueOf(0.0d);
     }
     factor2Value = newValue;
     refreshResult();
   }
 }