public Or.Builder<I> execute(final Predicate function) { current.setPredicate(function); or.getComponents().add((Predicate) current); return new Or.Builder<>(or); } }
public CloseableIterable<? extends Element> getEdgesRelatedTo2WhenSourceIsLessThan2OrDestinationIsMoreThan3() { // --------------------------------------------------------- final GetElements operation = new GetElements.Builder() .input(new EntitySeed(2)) .view(new View.Builder() .edge("edge", new ViewElementDefinition.Builder() .preAggregationFilter( new ElementFilter.Builder() .select(IdentifierType.SOURCE.name(), IdentifierType.DESTINATION.name()) .execute(new Or.Builder<>() .select(0) .execute(new IsLessThan(2)) .select(1) .execute(new IsMoreThan(3)) .build()) .build()) .build()) .build()) .build(); // --------------------------------------------------------- return runExample(operation, "When using an Or predicate with a multiple selected values, it is more complicated. " + "First, you need to select all the values you want: 'select(a, b, c)'. This will create an array of the selected values, [a, b, c]. " + "You then need to use the Or.Builder to build your Or predicate, using .select() then .execute(). " + "When selecting values in the Or.Builder you need to refer to the position in the [a,b,c] array. So to use property 'a', use position 0 - select(0)."); } }
public void firstItemIsLessThan2OrSecondItemIsMoreThan10() { // --------------------------------------------------------- final Or function = new Or.Builder() .select(0) .execute(new IsLessThan(2)) .select(1) .execute(new IsMoreThan(10)) .build(); // --------------------------------------------------------- runExample(function, "When using an Or predicate with multiple selected values, you need to use the Or.Builder to build your Or predicate, using .select() then .execute(). " + "When selecting values in the Or.Builder you need to refer to the position in the input array. I.e to use the first value use position 0 - select(0)." + "You can select multiple values to give to a predicate like isXLessThanY, this is achieved by passing 2 positions to the selec method - select(0, 1)", new Tuple2<>(1, 15), new Tuple2<>(1, 1), new Tuple2<>(15, 15), new Tuple2<>(15, 1), new Tuple2<>(1L, 15L), new Tuple1<>(1)); } }
final ElementFilter filter = new ElementFilter.Builder() .select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2) .execute(new Not<>(new Or.Builder<>() .select(0) .execute(new IsMoreThan(2))
final ElementFilter filter = new ElementFilter.Builder() .select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2) .execute(new Or.Builder<>() .select(0) .execute(new IsMoreThan(2))