Or

See javadoc - uk.gov.gchq.koryphe.impl.predicate.Or

Available since Koryphe version 1.0.0

Examples

Is less than 2 equal to 5 or is more than 10

When using an Or predicate with a single selected value you can just use the constructor new Or(predicates))'

Java
JSON
Full JSON
Python
final Or function = new Or<>(
        new IsLessThan(2),
        new IsEqual(5),
        new IsMoreThan(10)
);
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "IsLessThan",
    "orEqualTo" : false,
    "value" : 2
  }, {
    "class" : "IsEqual",
    "value" : 5
  }, {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  } ]
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan",
    "orEqualTo" : false,
    "value" : 2
  }, {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsEqual",
    "value" : 5
  }, {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  } ]
}
g.Or( 
  predicates=[ 
    g.IsLessThan( 
      value=2, 
      or_equal_to=False 
    ), 
    g.IsEqual( 
      value=5 
    ), 
    g.IsMoreThan( 
      value=10, 
      or_equal_to=False 
    ) 
  ] 
)

Input type:

java.lang.Object

Example inputs:

Input TypeInputResult
java.lang.Integer1true
java.lang.Integer2false
java.lang.Integer3false
java.lang.Integer5true
java.lang.Integer15true
java.lang.Long1false
java.lang.Long3false
java.lang.Long5false

Is less than 2 equal to 5 or is more than 10

When using an Or predicate with a single selected value you can just use the constructor new Or(predicates))'

Java
JSON
Full JSON
Python
final Or function = new Or<>(
        new IsLessThan(2),
        new IsEqual(5),
        new IsMoreThan(10)
);
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "IsLessThan",
    "orEqualTo" : false,
    "value" : 2
  }, {
    "class" : "IsEqual",
    "value" : 5
  }, {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  } ]
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan",
    "orEqualTo" : false,
    "value" : 2
  }, {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsEqual",
    "value" : 5
  }, {
    "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
    "orEqualTo" : false,
    "value" : 10
  } ]
}
g.Or( 
  predicates=[ 
    g.IsLessThan( 
      or_equal_to=False, 
      value=2 
    ), 
    g.IsEqual( 
      value=5 
    ), 
    g.IsMoreThan( 
      or_equal_to=False, 
      value=10 
    ) 
  ] 
)

Input type:

java.lang.Object

Example inputs:

Input TypeInputResult
java.lang.Integer1true
java.lang.Integer2false
java.lang.Integer3false
java.lang.Integer5true
java.lang.Integer15true
java.lang.Long1false
java.lang.Long3false
java.lang.Long5false

First item is less than 2 or second item is more than 10

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 select method - select(0, 1)

Java
JSON
Full JSON
Python
final Or function = new Or.Builder()
        .select(0)
        .execute(new IsLessThan(2))
        .select(1)
        .execute(new IsMoreThan(10))
        .build();
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "IntegerTupleAdaptedPredicate",
    "selection" : [ 0 ],
    "predicate" : {
      "class" : "IsLessThan",
      "orEqualTo" : false,
      "value" : 2
    }
  }, {
    "class" : "IntegerTupleAdaptedPredicate",
    "selection" : [ 1 ],
    "predicate" : {
      "class" : "IsMoreThan",
      "orEqualTo" : false,
      "value" : 10
    }
  } ]
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.Or",
  "predicates" : [ {
    "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate",
    "selection" : [ 0 ],
    "predicate" : {
      "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan",
      "orEqualTo" : false,
      "value" : 2
    }
  }, {
    "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate",
    "selection" : [ 1 ],
    "predicate" : {
      "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan",
      "orEqualTo" : false,
      "value" : 10
    }
  } ]
}
g.Or( 
  predicates=[ 
    g.NestedPredicate( 
      predicate=g.IsLessThan( 
        value=2, 
        or_equal_to=False 
      ), 
      selection=[ 
        0 
      ] 
    ), 
    g.NestedPredicate( 
      predicate=g.IsMoreThan( 
        value=10, 
        or_equal_to=False 
      ), 
      selection=[ 
        1 
      ] 
    ) 
  ] 
)

Input type:

java.lang.Object

Example inputs:

Input TypeInputResult
[java.lang.Integer, java.lang.Integer][1, 15]true
[java.lang.Integer, java.lang.Integer][1, 1]true
[java.lang.Integer, java.lang.Integer][15, 15]true
[java.lang.Integer, java.lang.Integer][15, 1]false
[java.lang.Long, java.lang.Long][1, 15]false
[java.lang.Integer][1]true

results matching ""

    No results matching ""