use of org.activityinfo.model.type.FieldValue in project activityinfo by bedatadriven.
the class ComparisonOperator method apply.
@Override
public FieldValue apply(List<FieldValue> arguments) {
FieldValue a = arguments.get(0);
FieldValue b = arguments.get(1);
return BooleanFieldValue.valueOf(apply(a, b));
}
use of org.activityinfo.model.type.FieldValue in project activityinfo by bedatadriven.
the class IfFunction method apply.
@Override
public FieldValue apply(List<FieldValue> arguments) {
checkArity(arguments, 3);
BooleanFieldValue condition = toBoolean(arguments.get(0));
FieldValue ifTrue = arguments.get(1);
FieldValue ifFalse = arguments.get(2);
if (condition == BooleanFieldValue.TRUE) {
return ifTrue;
} else {
return ifFalse;
}
}
use of org.activityinfo.model.type.FieldValue in project activityinfo by bedatadriven.
the class CeilingFunctionTest method test.
@Test
public void test() {
assertThat(CeilingFunction.INSTANCE.apply(1.6), Matchers.equalTo(2.0));
assertThat(CeilingFunction.INSTANCE.apply(1.5), Matchers.equalTo(2.0));
assertThat(CeilingFunction.INSTANCE.apply(1.4), Matchers.equalTo(2.0));
assertThat(CeilingFunction.INSTANCE.apply(-1.6), Matchers.equalTo(-1.0));
assertThat(CeilingFunction.INSTANCE.apply(-1.5), Matchers.equalTo(-1.0));
assertThat(CeilingFunction.INSTANCE.apply(-1.4), Matchers.equalTo(-1.0));
assertThat(CeilingFunction.INSTANCE.apply(Collections.<FieldValue>singletonList(new Quantity(1.5))), Matchers.<FieldValue>equalTo(new Quantity(2.0)));
assertThat(CeilingFunction.INSTANCE.apply(Collections.<FieldValue>singletonList(new Quantity(-1.5))), Matchers.<FieldValue>equalTo(new Quantity(-1.0)));
}
use of org.activityinfo.model.type.FieldValue in project activityinfo by bedatadriven.
the class FloorFunctionTest method test.
@Test
public void test() {
assertThat(FloorFunction.INSTANCE.apply(1.6), Matchers.equalTo(1.0));
assertThat(FloorFunction.INSTANCE.apply(1.5), Matchers.equalTo(1.0));
assertThat(FloorFunction.INSTANCE.apply(1.4), Matchers.equalTo(1.0));
assertThat(FloorFunction.INSTANCE.apply(-1.6), Matchers.equalTo(-2.0));
assertThat(FloorFunction.INSTANCE.apply(-1.5), Matchers.equalTo(-2.0));
assertThat(FloorFunction.INSTANCE.apply(-1.4), Matchers.equalTo(-2.0));
assertThat(FloorFunction.INSTANCE.apply(Collections.<FieldValue>singletonList(new Quantity(1.5))), Matchers.<FieldValue>equalTo(new Quantity(1.0)));
assertThat(FloorFunction.INSTANCE.apply(Collections.<FieldValue>singletonList(new Quantity(-1.5))), Matchers.<FieldValue>equalTo(new Quantity(-2.0)));
}
use of org.activityinfo.model.type.FieldValue in project activityinfo by bedatadriven.
the class YearFracFunctionTest method evaluation.
@Test
public void evaluation() {
LocalDate x = new LocalDate(2016, 1, 1);
LocalDate y = new LocalDate(2017, 1, 1);
Quantity z = (Quantity) YearFracFunction.INSTANCE.apply(Arrays.<FieldValue>asList(x, y));
assertThat(z, equalTo(new Quantity(1.0)));
}
Aggregations