use of uk.gov.gchq.koryphe.impl.predicate.IsA in project gaffer-doc by gchq.
the class IfExample method applyPredicatesToInput.
public void applyPredicatesToInput() {
// ---------------------------------------------------------
final If<Comparable> predicate = new If<>(new IsA(Integer.class), new IsMoreThan(3), new Not<>(new IsA(String.class)));
// ---------------------------------------------------------
runExample(predicate, "This example tests first whether the input is an Integer. " + "If so, it is then tested to see if the value is greater than 3. " + "Otherwise, since it is not an Integer, we then test to see if it is NOT a String.", 2, 3, 5, "test", new HashMap<>(), new ArrayList<>());
}
use of uk.gov.gchq.koryphe.impl.predicate.IsA in project gaffer-doc by gchq.
the class IsAExample method isANumber.
public void isANumber() {
// ---------------------------------------------------------
final IsA function = new IsA(Number.class);
// ---------------------------------------------------------
runExample(function, null, 1, 2.5, "abc");
}
use of uk.gov.gchq.koryphe.impl.predicate.IsA in project Gaffer by gchq.
the class IfIT method shouldRunOtherwiseOperationsWhenConditionIsFalse.
@Test
public void shouldRunOtherwiseOperationsWhenConditionIsFalse() throws OperationException {
// Given
final If<Object, Object> ifOperation = new If<>();
ifOperation.setInput(INPUT_CAMEL_CASE);
ifOperation.setConditional(new Conditional(new IsA("java.lang.Integer")));
ifOperation.setThen(new Map<>(Lists.newArrayList(new ToUpperCase(), new ToList())));
ifOperation.setOtherwise(new Map<>(Lists.newArrayList(new ToLowerCase(), new ToList())));
// When
final Object output = graph.execute(ifOperation, getUser());
// Then
assertThat(output).isEqualTo(Lists.newArrayList(INPUT_CAMEL_CASE.toLowerCase())).isInstanceOf(List.class);
}
use of uk.gov.gchq.koryphe.impl.predicate.IsA in project Gaffer by gchq.
the class IfIT method shouldDoOtherwiseWhenConditionIsFalseAndNoThenOperation.
@Test
public void shouldDoOtherwiseWhenConditionIsFalseAndNoThenOperation() throws OperationException {
// Given
final If<Object, Object> ifOperation = new If<>();
ifOperation.setInput(INPUT_CAMEL_CASE);
ifOperation.setConditional(new Conditional(new IsA("java.lang.Integer")));
ifOperation.setOtherwise(new Map<>(Lists.newArrayList(new ToLowerCase(), new ToList())));
// When
final Object output = graph.execute(ifOperation, getUser());
// Then
assertThat(output).isEqualTo(Lists.newArrayList(INPUT_CAMEL_CASE.toLowerCase())).isInstanceOf(List.class);
}
use of uk.gov.gchq.koryphe.impl.predicate.IsA in project gaffer-doc by gchq.
the class IsAExample method isAString.
public void isAString() {
// ---------------------------------------------------------
final IsA function = new IsA(String.class);
// ---------------------------------------------------------
runExample(function, null, 1, 2.5, "abc");
}
Aggregations