Skip to content

Koryphe Predicates

Predicates from the Koryphe library.

AgeOff

Checks if a timestamp is recent based on a provided age off time. Javadoc

Input type: java.lang.Long

Example AgeOff in milliseconds
final AgeOff function = new AgeOff(100000L);
{
  "class" : "AgeOff",
  "ageOffTime" : 100000
}
g.AgeOff(
  age_off_time=100000
)

Example inputs:

Input Type Input Result
java.lang.String ClassCastException: java.lang.String cannot be cast to java.lang.Long
java.lang.Long 1667818781957 true
java.lang.Long 1667818681957 false
java.lang.Long 1667818881957 true
java.lang.String 1667818781957 ClassCastException: java.lang.String cannot be cast to java.lang.Long

And

Returns true if all of its predicates are true. Javadoc

Input type: uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example of is less than 3 and is more than 0
final And function = new And<>(
        new IsLessThan(3),
        new IsMoreThan(0)
);
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.And",
  "predicates" : [ {
    "class" : "IsLessThan",
    "orEqualTo" : false,
    "value" : 3
  }, {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : 0
  } ]
}
g.And(
  predicates=[
    g.IsLessThan(
      value=3,
      or_equal_to=False
    ),
    g.IsMoreThan(
      value=0,
      or_equal_to=False
    )
  ]
)

Example inputs:

Input Type Input Result
java.lang.Integer 0 false
java.lang.Integer 1 true
java.lang.Integer 2 true
java.lang.Integer 3 false
java.lang.Long 1 false
java.lang.Long 2 false
Example of first item less than 2 and second item more than 5
final And function = new And.Builder()
        .select(0)
        .execute(new IsLessThan(2))
        .select(1)
        .execute(new IsMoreThan(5))
        .build();
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.And",
  "predicates" : [ {
    "class" : "IntegerTupleAdaptedPredicate",
    "selection" : [ 0 ],
    "predicate" : {
      "class" : "IsLessThan",
      "orEqualTo" : false,
      "value" : 2
    }
  }, {
    "class" : "IntegerTupleAdaptedPredicate",
    "selection" : [ 1 ],
    "predicate" : {
      "class" : "IsMoreThan",
      "orEqualTo" : false,
      "value" : 5
    }
  } ]
}
g.And(
  predicates=[
    g.NestedPredicate(
      selection=[
        0
      ],
      predicate=g.IsLessThan(
        value=2,
        or_equal_to=False
      )
    ),
    g.NestedPredicate(
      selection=[
        1
      ],
      predicate=g.IsMoreThan(
        value=5,
        or_equal_to=False
      )
    )
  ]
)

Example inputs:

Input Type Input Result
[java.lang.Integer, java.lang.Integer] [1, 10] true
[java.lang.Integer, java.lang.Integer] [1, 1] false
[java.lang.Integer, java.lang.Integer] [10, 10] false
[java.lang.Integer, java.lang.Integer] [10, 1] false
[java.lang.Long, java.lang.Long] [1, 10] false
[java.lang.Integer] [1] false

AreEqual

Returns true if the two inputs are equal. Javadoc

Input type: java.lang.Object, java.lang.Object

Example AreEqual
final AreEqual function = new AreEqual();
{
  "class" : "AreEqual"
}
g.AreEqual()

Example inputs:

Input Type Input Result
[java.lang.Integer, java.lang.Double] [1, 1.0] false
[java.lang.Double, java.lang.Double] [2.5, 2.5] true
[java.lang.String, ] [, null] false
[java.lang.String, java.lang.String] [abc, abc] true

AreIn

Checks if a provided collection contains all the provided input values. Javadoc

Input type: java.util.Collection

Example AreIn Set
final AreIn function = new AreIn(1, 2, 3);
{
  "class" : "AreIn",
  "values" : [ 1, 2, 3 ]
}
g.AreIn(
  values=[
    1,
    2,
    3
  ]
)

Example inputs:

Input Type Input Result
java.util.HashSet [1, 2, 3] true
java.util.HashSet [1, 2, 3, 4] false
java.util.HashSet [4, 1] false
java.util.HashSet [1, 2] true
java.util.HashSet [] true

CollectionContains

Checks if a collection contains a provided value. Javadoc

Input type: java.util.Collection

Example CollectionContains
final CollectionContains function = new CollectionContains(1);
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.CollectionContains",
  "value" : 1
}
g.CollectionContains(
  value=1
)

Example inputs:

Input Type Input Result
java.util.HashSet [1, 2, 3] true
java.util.HashSet [1] true
java.util.HashSet [2] false
java.util.HashSet [] false

Exists

Checks the input exists. Javadoc

Input type: java.lang.Object

Example Exists
final Exists function = new Exists();
{
  "class" : "Exists"
}
g.Exists()

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
null false
java.lang.String true
java.lang.String abc true

If

Conditionally applies a predicate. Javadoc

Input type: uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example conditionally applying predicates to input

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.

final If<Comparable> predicate = new If<>(new IsA(Integer.class), new IsMoreThan(3), new Not<>(new IsA(String.class)));
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.If",
  "predicate" : {
    "class" : "IsA",
    "type" : "java.lang.Integer"
  },
  "then" : {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : 3
  },
  "otherwise" : {
    "class" : "Not",
    "predicate" : {
      "class" : "IsA",
      "type" : "java.lang.String"
    }
  }
}
g.If(
  predicate=g.IsA(
    type="java.lang.Integer"
  ),
  then=g.IsMoreThan(
    value=3,
    or_equal_to=False
  ),
  otherwise=g.Not(
    predicate=g.IsA(
      type="java.lang.String"
    )
  )
)

Example inputs:

Input Type Input Result
java.lang.Integer 2 false
java.lang.Integer 3 false
java.lang.Integer 5 true
java.lang.String test false
java.util.HashMap {} true
java.util.ArrayList [] true

Or

Returns true if any of the predicates are true. Javadoc

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

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).

Input type: uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example is less than 2 equal to 5 or is more than 10
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
  } ]
}
g.Or(
  predicates=[
    g.IsLessThan(
      value=2,
      or_equal_to=False
    ),
    g.IsEqual(
      value=5
    ),
    g.IsMoreThan(
      value=10,
      or_equal_to=False
    )
  ]
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
java.lang.Integer 2 false
java.lang.Integer 3 false
java.lang.Integer 5 true
java.lang.Integer 15 true
java.lang.Long 1 false
java.lang.Long 3 false
java.lang.Long 5 false
Example is less than 2 equal to 5 or is more than 10
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
  } ]
}
g.Or(
  predicates=[
    g.IsLessThan(
      value=2,
      or_equal_to=False
    ),
    g.IsEqual(
      value=5
    ),
    g.IsMoreThan(
      value=10,
      or_equal_to=False
    )
  ]
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
java.lang.Integer 2 false
java.lang.Integer 3 false
java.lang.Integer 5 true
java.lang.Integer 15 true
java.lang.Long 1 false
java.lang.Long 3 false
java.lang.Long 5 false
Example first item is less than 2 or second item is more than 10
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
    }
  } ]
}
g.Or(
  predicates=[
    g.NestedPredicate(
      selection=[
        0
      ],
      predicate=g.IsLessThan(
        value=2,
        or_equal_to=False
      )
    ),
    g.NestedPredicate(
      selection=[
        1
      ],
      predicate=g.IsMoreThan(
        value=10,
        or_equal_to=False
      )
    )
  ]
)

Example inputs:

Input Type Input Result
[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

Not

Returns the inverse of a predicate. Javadoc

Input type: uk.gov.gchq.koryphe.signature.Signature$UnknownGenericType

Example does not exist
final Not function = new Not<>(new Exists());
{
  "class" : "Not",
  "predicate" : {
    "class" : "Exists"
  }
}
g.Not(
  predicate=g.Exists()
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
null true
java.lang.String false
java.lang.String abc false
Example are not equal
final Not function = new Not<>(new AreEqual());
{
  "class" : "Not",
  "predicate" : {
    "class" : "AreEqual"
  }
}
g.Not(
  predicate=g.AreEqual()
)

Example inputs:

Input Type Input Result
[java.lang.Integer, java.lang.Double] [1, 1.0] true
[java.lang.Integer, java.lang.Integer] [1, 2] true
[java.lang.Double, java.lang.Double] [2.5, 2.5] false
[java.lang.String, ] [, null] true
[java.lang.String, java.lang.String] [abc, abc] false

InDateRange

Tests if a Comparable is within a provided range. By default the range is inclusive, this can be toggled using the startInclusive and endInclusive booleans. Javadoc

You can configure the start and end time strings using the following formats:

  • timestamp in milliseconds
  • yyyy/MM
  • yyyy/MM/dd
  • yyyy/MM/dd HH
  • yyyy/MM/dd HH:mm
  • yyyy/MM/dd HH:mm:ss

You can use a space, -, /, _, :, |, or . to separate the parts.

Input type: java.util.Date

Example InDateRange with day precision
final InDateRange function = new InDateRange.Builder()
        .start("2017/01/01")
        .end("2017/02/01")
        .build();
{
  "class" : "InDateRange",
  "start" : "2017/01/01",
  "end" : "2017/02/01"
}
g.InDateRange(
  start="2017/01/01",
  end="2017/02/01"
)

Example inputs:

Input Type Input Result
java.util.Date Fri Jan 01 00:00:00 GMT 2016 false
java.util.Date Sun Jan 01 00:00:00 GMT 2017 true
java.util.Date Sun Jan 01 01:00:00 GMT 2017 true
java.util.Date Sun Jan 01 23:59:59 GMT 2017 true
java.util.Date Wed Feb 01 00:00:00 GMT 2017 true
java.util.Date Wed Feb 01 00:00:01 GMT 2017 false
null false
Example InDateRange with second precision
final InDateRange function = new InDateRange.Builder()
        .start("2017/01/01 01:30:10")
        .end("2017/01/01 01:30:50")
        .build();
{
  "class" : "InDateRange",
  "start" : "2017/01/01 01:30:10",
  "end" : "2017/01/01 01:30:50"
}
g.InDateRange(
  start="2017/01/01 01:30:10",
  end="2017/01/01 01:30:50"
)

Example inputs:

Input Type Input Result
java.util.Date Sun Jan 01 01:30:09 GMT 2017 false
java.util.Date Sun Jan 01 01:30:10 GMT 2017 true
java.util.Date Sun Jan 01 01:30:20 GMT 2017 true
java.util.Date Sun Jan 01 01:30:50 GMT 2017 true
java.util.Date Sun Jan 01 01:30:51 GMT 2017 false
null false
Example InDateRange with timestamps
final InDateRange function = new InDateRange.Builder()
        .start("1483315200")
        .end("1485907200")
        .build();
{
  "class" : "InDateRange",
  "start" : "1483315200",
  "end" : "1485907200"
}
g.InDateRange(
  start="1483315200",
  end="1485907200"
)

Example inputs:

Input Type Input Result
java.util.Date Sun Jan 18 05:01:55 GMT 1970 false
java.util.Date Sun Jan 18 05:01:55 GMT 1970 true
java.util.Date Sun Jan 18 05:01:56 GMT 1970 true
java.util.Date Sun Jan 18 05:45:07 GMT 1970 true
java.util.Date Sun Jan 18 05:45:07 GMT 1970 false
null false
Example of range exclusive
final InDateRange function = new InDateRange.Builder()
        .start("2017/01/01")
        .end("2017/02/01")
        .startInclusive(false)
        .endInclusive(false)
        .build();
{
  "class" : "InDateRange",
  "start" : "2017/01/01",
  "end" : "2017/02/01",
  "startInclusive" : false,
  "endInclusive" : false
}
g.InDateRange(
  start="2017/01/01",
  end="2017/02/01",
  start_inclusive=False,
  end_inclusive=False
)

Example inputs:

Input Type Input Result
java.util.Date Fri Jan 01 00:00:00 GMT 2016 false
java.util.Date Sun Jan 01 00:00:00 GMT 2017 false
java.util.Date Sun Jan 01 01:00:00 GMT 2017 true
java.util.Date Sun Jan 01 23:59:59 GMT 2017 true
java.util.Date Wed Feb 01 00:00:00 GMT 2017 false
java.util.Date Wed Feb 01 00:00:01 GMT 2017 false
null false
Example of within the last week

If the end of the range is not specified then the end of the range is unbounded.

final InDateRange function = new InDateRange.Builder()
        .startOffset(-7L)
        // end is not set - it is unbounded
        .offsetUnit(TimeUnit.DAY)
        .build();
{
  "class" : "InDateRange",
  "startOffset" : -7,
  "offsetUnit" : "DAY"
}
g.InDateRange(
  start_offset=-7,
  offset_unit="DAY"
)

Example inputs:

Input Type Input Result
java.util.Date Sun Oct 30 11:00:11 GMT 2022 false
java.util.Date Tue Nov 01 11:00:11 GMT 2022 true
java.util.Date Sun Nov 06 11:00:11 GMT 2022 true
java.util.Date Mon Nov 07 11:00:11 GMT 2022 true
null false
Example of exactly 7 hours ago
final InDateRange function = new InDateRange.Builder()
        .startOffset(-7L)
        .endOffset(-6L)
        .endInclusive(false)
        .offsetUnit(TimeUnit.HOUR)
        .build();
{
  "class" : "InDateRange",
  "startOffset" : -7,
  "endOffset" : -6,
  "endInclusive" : false,
  "offsetUnit" : "HOUR"
}
g.InDateRange(
  start_offset=-7,
  end_offset=-6,
  offset_unit="HOUR",
  end_inclusive=False
)

Example inputs:

Input Type Input Result
java.util.Date Mon Nov 07 03:00:12 GMT 2022 false
java.util.Date Mon Nov 07 04:00:22 GMT 2022 true
java.util.Date Mon Nov 07 05:00:02 GMT 2022 true
java.util.Date Mon Nov 07 05:00:22 GMT 2022 false
java.util.Date Mon Nov 07 11:00:12 GMT 2022 false
null false

InDateRangeDual

Tests for if there is an overlap between the provided and configured date ranges. Javadoc

The provided start and end dates do not need to be within the range configured, there only needs to be an overlap. To ensure the provided start and/or end are wholly within and contained by the configured range set the startFullyContained and/or endFullyContained booleans to be true (false by default).

By default, the start and end date comparison is inclusive, this can be changed using the startInclusive and endInclusive booleans. Note that dates with and without times are not treated as the same, e.g. 2017/01/01 is considered to be 2017/01/01 00:00, see below for an example.

If the start or end are not set they will be treated as unbounded. Input formats are the same as used by InDateRange.

Input type: java.util.Date, java.util.Date

Example with entirely uncontained range

This is the default when startFullyContained and endFullyContained are not specified, startInclusive and endInclusive are not specified and so these default to true. This will accept any date range containing values which overlap with the configured range. Not all values need to be overlapping. The configured range does include midnight/00:00:00 for the start or end date. This means that all times on "2017/03/01" are included and midnight of "2017/08/01" is included.

final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(false) // Doesn't need to be specified as it is the default
        .endFullyContained(false) // Doesn't need to be specified as it is the default
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : false
}
g.InDateRangeDual(
  start="2017/03/01",
  end="2017/08/01",
  start_fully_contained=False,
  end_fully_contained=False
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Wed Feb 01 00:00:00 GMT 2017] false
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Sat Apr 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Mon May 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Fri Sep 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Fri Sep 01 00:00:00 BST 2017, Sun Oct 01 00:00:00 BST 2017] false
[ ,] [null, null] false
Example with contained start range

This will accept date ranges containing values overlapping the configured range which do not have values before the start date.

final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(true)
        .endFullyContained(false) // Doesn't need to be specified as it is the default
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : false,
  "startFullyContained" : true
}
g.InDateRangeDual(
  start="2017/03/01",
  end="2017/08/01",
  start_fully_contained=True,
  end_fully_contained=False
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Wed Feb 01 00:00:00 GMT 2017] false
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Sat Apr 01 00:00:00 BST 2017] false
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Mon May 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Fri Sep 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Fri Sep 01 00:00:00 BST 2017, Sun Oct 01 00:00:00 BST 2017] false
[ ,] [null, null] false
Example with entirely contained range

This will only accept ranges where all values fall between the configured start (including midnight/00:00:00) and before the configured end (including midnight/00:00:00 on that date).

final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(true)
        .endFullyContained(true)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : true,
  "startFullyContained" : true
}
g.InDateRangeDual(
  start="2017/03/01",
  end="2017/08/01",
  start_fully_contained=True,
  end_fully_contained=True
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Wed Feb 01 00:00:00 GMT 2017] false
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Sat Apr 01 00:00:00 BST 2017] false
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Mon May 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Fri Sep 01 00:00:00 BST 2017] false
[java.util.Date, java.util.Date] [Fri Sep 01 00:00:00 BST 2017, Sun Oct 01 00:00:00 BST 2017] false
[java.util.Date, java.util.Date] [Wed Mar 01 00:00:00 GMT 2017, Tue Aug 01 00:00:00 BST 2017] true
[ ,] [null, null] false
Example with exclusive range

This will accept any date range containing values which overlap with the configured range. The configured range doesn't include midnight/00:00:00 for the start or end date. This means that midnight of "2017/03/01" is not included and no part of "2017/08/01" is included.

final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startInclusive(false)
        .endInclusive(false)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endInclusive" : false,
  "startInclusive" : false
}
g.InDateRangeDual(
  start="2017/03/01",
  end="2017/08/01",
  start_inclusive=False,
  end_inclusive=False
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Wed Feb 01 00:00:00 GMT 2017, Wed Mar 01 00:00:00 GMT 2017] false
[java.util.Date, java.util.Date] [Wed Feb 01 00:00:00 GMT 2017, Wed Mar 01 00:00:01 GMT 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Mon May 01 00:00:00 BST 2017] true
[java.util.Date, java.util.Date] [Tue Aug 01 00:00:00 BST 2017, Tue May 01 00:00:00 BST 2018] false
[java.util.Date, java.util.Date] [Tue Aug 01 00:00:01 BST 2017, Tue May 01 00:00:00 BST 2018] false
Example with entirely contained and exclusive range

This will only accept ranges where all values fall between the configured start (after midnight/00:00:00) and before the configured end.

final InDateRangeDual function = new InDateRangeDual.Builder()
        .start("2017/03/01")
        .end("2017/08/01")
        .startFullyContained(true)
        .endFullyContained(true)
        .startInclusive(false)
        .endInclusive(false)
        .build();
{
  "class" : "InDateRangeDual",
  "start" : "2017/03/01",
  "end" : "2017/08/01",
  "endFullyContained" : true,
  "startFullyContained" : true,
  "endInclusive" : false,
  "startInclusive" : false
}
g.InDateRangeDual(
  start="2017/03/01",
  end="2017/08/01",
  start_fully_contained=True,
  end_fully_contained=True,
  start_inclusive=False,
  end_inclusive=False
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Wed Mar 01 00:00:00 GMT 2017, Tue Aug 01 00:00:00 BST 2017] false
[java.util.Date, java.util.Date] [Wed Mar 01 00:00:00 GMT 2017, Mon Jul 31 23:59:59 BST 2017] false
[java.util.Date, java.util.Date] [Wed Mar 01 00:00:01 GMT 2017, Mon Jul 31 23:59:59 BST 2017] true
[java.util.Date, java.util.Date] [Sat Apr 01 00:00:00 BST 2017, Mon May 01 00:00:00 BST 2017] true
Example with unbounded range

This will accept any date range containing overlapping values of before the configured end (including this date at midnight/00:00:00).

final InDateRangeDual function = new InDateRangeDual.Builder()
        .end("2017/08/01")
        .build();
{
  "class" : "InDateRangeDual",
  "end" : "2017/08/01"
}
g.InDateRangeDual(
  end="2017/08/01"
)

Example inputs:

Input Type Input Result
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Mon Jan 01 00:00:00 GMT 2018] true
[java.util.Date, java.util.Date] [Sun Jan 01 00:00:00 GMT 2017, Wed Aug 01 00:00:00 BST 2018] true
[java.util.Date, java.util.Date] [Thu Jan 01 00:00:00 GMT 2015, Tue Aug 01 00:00:00 BST 2023] true
[java.util.Date, java.util.Date] [Tue Aug 01 00:00:00 BST 2017, Tue Aug 01 00:00:00 BST 2023] true
[java.util.Date, java.util.Date] [Tue Aug 01 00:00:01 BST 2017, Tue Aug 01 00:00:00 BST 2023] false
[java.util.Date, java.util.Date] [Thu Jan 01 00:00:00 GMT 2022, Tue Aug 01 00:00:00 BST 2023] false

InRange

Checks if a comparable is within a provided range. Javadoc

Input type: java.lang.Comparable

Example of Long 5 to 10
final InRange function = new InRange.Builder<Long>()
        .start(5L)
        .end(10L)
        .build();
{
  "class" : "InRange",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  }
}
g.InRange(
  start=g.long(5),
  end=g.long(10)
)

Example inputs:

Input Type Input Result
java.lang.Long -5 false
java.lang.Long 1 false
java.lang.Long 5 true
java.lang.Long 7 true
java.lang.Long 10 true
java.lang.Long 20 false
java.lang.Integer 7 ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String 7 ClassCastException: java.lang.Long cannot be cast to java.lang.String
null false
Example of Long 5 to 10 exclusive
final InRange function = new InRange.Builder<Long>()
        .start(5L)
        .end(10L)
        .startInclusive(false)
        .endInclusive(false)
        .build();
{
  "class" : "InRange",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  },
  "startInclusive" : false,
  "endInclusive" : false
}
g.InRange(
  start=g.long(5),
  end=g.long(10),
  start_inclusive=False,
  end_inclusive=False
)

Example inputs:

Input Type Input Result
java.lang.Long -5 false
java.lang.Long 1 false
java.lang.Long 5 false
java.lang.Long 7 true
java.lang.Long 10 false
java.lang.Long 20 false
java.lang.Integer 7 ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String 7 ClassCastException: java.lang.Long cannot be cast to java.lang.String
null false
Example of Long 5 less than 10

If the start of the range is not specified then the start of the range is unbounded.

final InRange function = new InRange.Builder<Long>()
        .end(10L)
        .endInclusive(false)
        .build();
{
  "class" : "InRange",
  "end" : {
    "Long" : 10
  },
  "endInclusive" : false
}
g.InRange(
  end=g.long(10),
  end_inclusive=False
)

Example inputs:

Input Type Input Result
java.lang.Long -5 true
java.lang.Long 1 true
java.lang.Long 5 true
java.lang.Long 7 true
java.lang.Long 10 false
java.lang.Long 20 false
java.lang.Integer 7 ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String 7 ClassCastException: java.lang.Long cannot be cast to java.lang.String
null false
Example of String 'B' to 'D'
final InRange function = new InRange.Builder<String>()
        .start("B")
        .end("D")
        .build();
{
  "class" : "InRange",
  "start" : "B",
  "end" : "D"
}
g.InRange(
  start="B",
  end="D"
)

Example inputs:

Input Type Input Result
java.lang.String A false
java.lang.String B true
java.lang.String C true
java.lang.String D true
java.lang.String c false
java.lang.Integer 1 ClassCastException: java.lang.String cannot be cast to java.lang.Integer
null false

InRangeDual

Checks if two comparables (a start and an end) are within a provided range. Javadoc

Input type: java.lang.Comparable, java.lang.Comparable

Example of Long overlapping range
final InRangeDual function = new InRangeDual.Builder<Long>()
        .start(5L)
        .end(10L)
        .startFullyContained(false)
        .endFullyContained(false)
        .build();
{
  "class" : "InRangeDual",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  },
  "endFullyContained" : false,
  "startFullyContained" : false
}
g.InRangeDual(
    start=g.long(5),
    end=g.long(10),
    start_fully_contained=False,
    end_fully_contained=False
)

Example inputs:

Input Type Input Result
[java.lang.Long, java.lang.Long] [1, 4] false
[java.lang.Long, java.lang.Long] [1, 7] true
[java.lang.Long, java.lang.Long] [6, 7] true
[java.lang.Long, java.lang.Long] [7, 11] true
[java.lang.Long, java.lang.Long] [11, 20] false
[ ,] [null, null] false
Example of Long end overlapping range
final InRangeDual function = new InRangeDual.Builder<Long>()
        .start(5L)
        .end(10L)
        .startFullyContained(true)
        .endFullyContained(false)
        .build();
{
  "class" : "InRangeDual",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  },
  "endFullyContained" : false,
  "startFullyContained" : true
}
g.InRangeDual(
  start=g.long(5),
  end=g.long(10),
  start_fully_contained=True,
  end_fully_contained=False
)

Example inputs:

Input Type Input Result
[java.lang.Long, java.lang.Long] [1, 4] false
[java.lang.Long, java.lang.Long] [1, 7] false
[java.lang.Long, java.lang.Long] [6, 7] true
[java.lang.Long, java.lang.Long] [7, 11] true
[java.lang.Long, java.lang.Long] [11, 20] false
[ ,] [null, null] false
Example of Long non overlapping range
final InRangeDual function = new InRangeDual.Builder<Long>()
        .start(5L)
        .end(10L)
        .startFullyContained(true)
        .endFullyContained(true)
        .build();
{
  "class" : "InRangeDual",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  },
  "endFullyContained" : true,
  "startFullyContained" : true
}
g.InRangeDual(
  start=g.long(5),
  end=g.long(10),
  start_fully_contained=True,
  end_fully_contained=True
)

Example inputs:

Input Type Input Result
[java.lang.Long, java.lang.Long] [1, 4] false
[java.lang.Long, java.lang.Long] [1, 7] false
[java.lang.Long, java.lang.Long] [6, 7] true
[java.lang.Long, java.lang.Long] [7, 11] false
[java.lang.Long, java.lang.Long] [11, 20] false
[ ,] [null, null] false
Example Long less than 10

If the start of the range is not specified then the start of the range is unbounded.

final InRangeDual function = new InRangeDual.Builder<Long>()
        .end(10L)
        .endInclusive(false)
        .build();
{
  "class" : "InRangeDual",
  "end" : {
    "Long" : 10
  },
  "endInclusive" : false
}
g.InRangeDual(
  end=g.long(10),
  end_inclusive=False
)

Example inputs:

Input Type Input Result
[java.lang.Long, java.lang.Long] [-5, -1] true
[java.lang.Long, java.lang.Long] [1, 6] true
[java.lang.Long, java.lang.Long] [6, 6] true
[java.lang.Long, java.lang.Long] [6, 7] true
[java.lang.Long, java.lang.Long] [6, 10] true
[java.lang.Long, java.lang.Long] [10, 20] false
[java.lang.Integer, java.lang.Integer] [6, 7] IllegalArgumentException: Input tuple values do not match the required function input types
[java.lang.String, java.lang.String] [5, 7] IllegalArgumentException: Input tuple values do not match the required function input types
[ ,] [null, null] false

InTimeRange

Functionally identical to InDateRange, except that it uses Long as the timestamp input type. By default, checks are carried out assuming the data will be in milliseconds. If this is not the case, the time unit can be changed using the timeUnit property. Javadoc

Input type: java.lang.Long

Example with time unit microseconds
final InTimeRange function = new InTimeRange.Builder()
        .start("2017/01/01 01:30:10")
        .end("2017/01/01 01:30:50")
        .timeUnit(TimeUnit.MICROSECOND)
        .build();
{
  "class" : "InTimeRange",
  "start" : "2017/01/01 01:30:10",
  "end" : "2017/01/01 01:30:50",
  "timeUnit" : "MICROSECOND"
}
g.InTimeRange(
  start="2017/01/01 01:30:10",
  end="2017/01/01 01:30:50",
  time_unit="MICROSECOND"
)

Example inputs:

Input Type Input Result
java.lang.Long 1483234209000000 false
java.lang.Long 1483234210000000 true
java.lang.Long 1483234220000000 true
java.lang.Long 1483234250000000 true
java.lang.Long 1483234251000000 false
null false

InTimeRangeDual

Functionally identical to InDateRangeDual. By default, checks are carried out assuming the data will be in milliseconds. If this is not the case, the time unit can be changed using the timeUnit property. Javadoc

IsA

Checks if an input is an instance of a class. Javadoc

Input type: java.lang.Object

Example with String
final IsA function = new IsA(String.class);
{
  "class" : "IsA",
  "type" : "java.lang.String"
}
g.IsA(
  type="java.lang.String"
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
java.lang.Double 2.5 false
java.lang.String abc true
Example with Number
final IsA function = new IsA(Number.class);
{
  "class" : "IsA",
  "type" : "java.lang.Number"
}
g.IsA(
  type="java.lang.Number"
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
java.lang.Double 2.5 true
java.lang.String abc false

IsEqual

Checks if an input is equal to a provided value. Javadoc

Input type: java.lang.Object

Example equal to Integer 5
final IsEqual function = new IsEqual(5);
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.IsEqual",
  "value" : 5
}
g.IsEqual(
  value=5
)

Example inputs:

Input Type Input Result
java.lang.Integer 5 true
java.lang.Long 5 false
java.lang.String 5 false
java.lang.Character 5 false
Example equal to String 5
final IsEqual function = new IsEqual("5");
{
  "class" : "IsEqual",
  "value" : "5"
}
g.IsEqual(
  value="5"
)

Example inputs:

Input Type Input Result
java.lang.Integer 5 false
java.lang.Long 5 false
java.lang.String 5 true
java.lang.Character 5 false

IsFalse

Checks if an input boolean is false. Javadoc

Input type: java.lang.Boolean

Example IsFalse
final IsFalse function = new IsFalse();
{
  "class" : "IsFalse"
}
g.IsFalse()

Example inputs:

Input Type Input Result
java.lang.Boolean true false
java.lang.Boolean false true
null false
java.lang.String true ClassCastException: java.lang.String cannot be cast to java.lang.Boolean

IsTrue

Checks if an input boolean is true. Javadoc

Input type: java.lang.Boolean

Example IsTrue
final IsTrue function = new IsTrue();
{
  "class" : "IsTrue"
}
g.IsTrue()

Example inputs:

Input Type Input Result
java.lang.Boolean true true
java.lang.Boolean false false
null false
java.lang.String true ClassCastException: java.lang.String cannot be cast to java.lang.Boolean

IsIn

Checks if an input is in a set of allowed values. Javadoc

Input type: java.lang.Object

Example IsIn
final IsIn function = new IsIn(5, 5L, "5", '5');
{
  "class" : "IsIn",
  "values" : [ 5, {
    "Long" : 5
  }, "5", {
    "Character" : "5"
  } ]
}
g.IsIn(
  values=[
    5,
    g.long(5),
    "5",
    {'java.lang.Character': '5'}
  ]
)

Example inputs:

Input Type Input Result
java.lang.Integer 5 true
java.lang.Long 5 true
java.lang.String 5 true
java.lang.Character 5 true
java.lang.Integer 1 false
java.lang.Long 1 false
java.lang.String 1 false
java.lang.Character 1 false

IsLessThan

Checks if a comparable is less than a provided value. Javadoc

Input type: java.lang.Comparable

Example IsLessThan with Integer 5
final IsLessThan function = new IsLessThan(5);
{
  "class" : "IsLessThan",
  "orEqualTo" : false,
  "value" : 5
}
g.IsLessThan(
  value=5,
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
java.lang.Long 1 false
java.lang.Integer 5 false
java.lang.Long 5 false
java.lang.Integer 10 false
java.lang.Long 10 false
java.lang.String 1 false
Example IsLessThan or equal with Integer 5
final IsLessThan function = new IsLessThan(5, true);
{
  "class" : "IsLessThan",
  "orEqualTo" : true,
  "value" : 5
}
g.IsLessThan(
  value=5,
  or_equal_to=True
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 true
java.lang.Long 1 false
java.lang.Integer 5 true
java.lang.Long 5 false
java.lang.Integer 10 false
java.lang.Long 10 false
java.lang.String 1 false
Example IsLessThan with String 'B'
final IsLessThan function = new IsLessThan("B");
{
  "class" : "IsLessThan",
  "orEqualTo" : false,
  "value" : "B"
}
g.IsLessThan(
  value="B",
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
java.lang.String A true
java.lang.String B false
java.lang.String C false

IsMoreThan

Checks if a comparable is more than a provided value. Javadoc

Input type: java.lang.Comparable

Example IsMoreThan with Integer 5
final IsMoreThan function = new IsMoreThan(5);
{
  "class" : "IsMoreThan",
  "orEqualTo" : false,
  "value" : 5
}
g.IsMoreThan(
  value=5,
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
java.lang.Integer 5 false
java.lang.Integer 10 true
Example IsMoreThan or equal with Integer 5
final IsMoreThan function = new IsMoreThan(5, true);
{
  "class" : "IsMoreThan",
  "orEqualTo" : true,
  "value" : 5
}
g.IsMoreThan(
  value=5,
  or_equal_to=True
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
java.lang.Integer 5 true
java.lang.Integer 10 true
Example IsMoreThan with String 'B'
final IsMoreThan function = new IsMoreThan("B");
{
  "class" : "IsMoreThan",
  "orEqualTo" : false,
  "value" : "B"
}
g.IsMoreThan(
  value="B",
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.Integer 1 false
java.lang.String A false
java.lang.String B false
java.lang.String C true

IsLongerThan

Checks if the length of an input is more than a value. Javadoc

Input type: java.lang.Object

Example testing size/length attribute is greater than 5
final IsLongerThan predicate = new IsLongerThan(5);
{
  "class" : "IsLongerThan",
  "minLength" : 5,
  "orEqualTo" : false
}
g.IsLongerThan(
  min_length=5,
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.String testString true
java.lang.String aTest false
[Ljava.lang.String; [null, null, null, null, null] false
[Ljava.lang.String; [null, null, null, null, null, null, null, null, null, null] true
java.util.Arrays$ArrayList [0, 1, 2, 3, 4, 5] true
Example testing size/length attribute is greater than or equal to 5
final IsLongerThan predicate = new IsLongerThan(5, true);
{
  "class" : "IsLongerThan",
  "minLength" : 5,
  "orEqualTo" : true
}
g.IsLongerThan(
  min_length=5,
  or_equal_to=True
)

Example inputs:

Input Type Input Result
java.lang.String test false
java.lang.String testString true
java.lang.String aTest true
[Ljava.lang.String; [null, null, null, null, null] true
[Ljava.lang.String; [null, null, null, null, null, null, null, null, null, null] true
java.util.Arrays$ArrayList [0, 1, 2, 3, 4, 5] true

IsShorterThan

Checks if the length of an input is more than than a value. Javadoc

Input type: java.lang.Object

Example testing size/length attribute is shorter than 4
final IsShorterThan function = new IsShorterThan(4);
{
  "class" : "IsShorterThan",
  "maxLength" : 4,
  "orEqualTo" : false
}
g.IsShorterThan(
  max_length=4,
  or_equal_to=False
)

Example inputs:

Input Type Input Result
java.lang.String 123 true
java.lang.String 1234 false
[Ljava.lang.Integer; [1, 2, 3] true
[Ljava.lang.Integer; [1, 2, 3, 4] false
java.util.ArrayList [1, 2, 3] true
java.util.ArrayList [1, 2, 3, 4] false
java.util.HashMap {1=a, 2=b, 3=c} true
java.util.HashMap {4=d} true
java.lang.Integer 10000 IllegalArgumentException: Could not determine the size of the provided value
java.lang.Long 10000 IllegalArgumentException: Could not determine the size of the provided value

IsXLessThanY

Checks the first comparable is less than the second comparable. Javadoc

Input type: java.lang.Comparable, java.lang.Comparable

Example IsXLessThanY
final IsXLessThanY function = new IsXLessThanY();
{
  "class" : "IsXLessThanY"
}
g.IsXLessThanY()

Example inputs:

Input Type Input Result
[java.lang.Integer, java.lang.Integer] [1, 5] true
[java.lang.Integer, java.lang.Integer] [5, 5] false
[java.lang.Integer, java.lang.Integer] [10, 5] false
[java.lang.Long, java.lang.Integer] [1, 5] false
[java.lang.Long, java.lang.Long] [1, 5] true
[java.lang.Long, java.lang.Long] [5, 5] false
[java.lang.Long, java.lang.Long] [10, 5] false
[java.lang.Integer, java.lang.Long] [1, 5] false
[java.lang.String, java.lang.String] [bcd, cde] true
[java.lang.String, java.lang.String] [bcd, abc] false
[java.lang.String, java.lang.Integer] [1, 5] false

IsXMoreThanY

Checks the first comparable is more than the second comparable. Javadoc

Input type: java.lang.Comparable, java.lang.Comparable

Example IsXMoreThanY
final IsXMoreThanY function = new IsXMoreThanY();
{
  "class" : "IsXMoreThanY"
}
g.IsXMoreThanY()

Example inputs:

Input Type Input Result
[java.lang.Integer, java.lang.Integer] [1, 5] false
[java.lang.Integer, java.lang.Integer] [5, 5] false
[java.lang.Integer, java.lang.Integer] [10, 5] true
[java.lang.Long, java.lang.Integer] [10, 5] false
[java.lang.Long, java.lang.Long] [1, 5] false
[java.lang.Long, java.lang.Long] [5, 5] false
[java.lang.Long, java.lang.Long] [10, 5] true
[java.lang.Integer, java.lang.Long] [10, 5] false
[java.lang.String, java.lang.String] [bcd, cde] false
[java.lang.String, java.lang.String] [bcd, abc] true
[java.lang.String, java.lang.Integer] [10, 5] false

MapContains

Checks if a map contains a given key. Javadoc

Input type: java.util.Map

Example MapContains
final MapContains function = new MapContains("a");
{
  "class" : "MapContains",
  "key" : "a"
}
g.MapContains(
  key="a"
)

Example inputs:

Input Type Input Result
java.util.HashMap {a=1, b=2, c=3} true
java.util.HashMap {b=2, c=3} false
java.util.HashMap {a=null, b=2, c=3} true

MapContainsPredicate

Checks if a map contains a key that matches a predicate. Javadoc

Input type: java.util.Map

Example of MapContainsPredicate with Regex Pedicate
final MapContainsPredicate function = new MapContainsPredicate(new Regex("a.*"));
{
  "class" : "MapContainsPredicate",
  "keyPredicate" : {
    "class" : "Regex",
    "value" : {
      "java.util.regex.Pattern" : "a.*"
    }
  }
}
g.MapContainsPredicate(
  key_predicate=g.Regex(
    value={"java.util.regex.Pattern": "a.*"}
  )
)

Example inputs:

Input Type Input Result
java.util.HashMap {a1=1, a2=2, b=2, c=3} true
java.util.HashMap {b=2, c=3} false
java.util.HashMap {a=null, b=2, c=3} true

PredicateMap

Extracts a value from a map then applies the predicate to it. Javadoc

Input type: java.util.Map

Example FreqMap is more than 2
final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L));
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "IsMoreThan",
    "orEqualTo" : false,
    "value" : {
      "Long" : 2
    }
  },
  "key" : "key1"
}
g.PredicateMap(
  key="key1",
  predicate=g.IsMoreThan(
    value=g.long(2),
    or_equal_to=False
  )
)

Example inputs:

Input Type Input Result
uk.gov.gchq.gaffer.types.FreqMap {key1=1} false
uk.gov.gchq.gaffer.types.FreqMap {key1=2} false
uk.gov.gchq.gaffer.types.FreqMap {key1=3} true
uk.gov.gchq.gaffer.types.FreqMap {key1=3, key2=0} true
uk.gov.gchq.gaffer.types.FreqMap {key2=3} false
Example FreqMap is more than or equal to 2
final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L, true));
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "IsMoreThan",
    "orEqualTo" : true,
    "value" : {
      "Long" : 2
    }
  },
  "key" : "key1"
}
g.PredicateMap(
  key="key1",
  predicate=g.IsMoreThan(
    value=g.long(2),
    or_equal_to=True
  )
)

Example inputs:

Input Type Input Result
uk.gov.gchq.gaffer.types.FreqMap {key1=1} false
uk.gov.gchq.gaffer.types.FreqMap {key1=2} true
uk.gov.gchq.gaffer.types.FreqMap {key1=3} true
uk.gov.gchq.gaffer.types.FreqMap {key1=3, key2=0} true
uk.gov.gchq.gaffer.types.FreqMap {key2=3} false
Example Map with date key having value that exists
final PredicateMap function = new PredicateMap(new Date(0L), new Exists());
{
  "class" : "PredicateMap",
  "predicate" : {
    "class" : "Exists"
  },
  "key" : {
    "Date" : 0
  }
}
g.PredicateMap(
  key=g.date(0),
  predicate=g.Exists()
)

Example inputs:

Input Type Input Result
java.util.HashMap {Thu Jan 01 01:00:00 GMT 1970=1} true
java.util.HashMap {Mon Nov 07 11:00:16 GMT 2022=2} false

StringContains

Checks if a string contains some value. Javadoc

Note

The StringContains predicate is case sensitive by default, hence only exact matches are found.

Input type: java.lang.String

Example StringContains
final StringContains function = new StringContains("test");
{
  "class" : "StringContains",
  "value" : "test",
  "ignoreCase" : false
}
g.StringContains(
  value="test",
  ignore_case=False
)

Example inputs:

Input Type Input Result
java.lang.String This is a Test false
java.lang.String Test false
java.lang.String test true
Example StringContains ignoring case
final StringContains function = new StringContains("test", true);
{
  "class" : "StringContains",
  "value" : "test",
  "ignoreCase" : true
}
g.StringContains(
  value="test",
  ignore_case=True
)

Example inputs:

Input Type Input Result
java.lang.String This is a Test true
java.lang.String Test true
java.lang.String test true

Regex

Checks if a string matches a pattern. Javadoc

Input type: java.lang.String

Example abc
final Regex function = new Regex("[a-d0-4]");
{
  "class" : "Regex",
  "value" : {
    "java.util.regex.Pattern" : "[a-d0-4]"
  }
}
g.Regex(
  value={'java.util.regex.Pattern': '[a-d0-4]'}
)

Example inputs:

Input Type Input Result
java.lang.String a true
java.lang.String z false
java.lang.String az false
java.lang.Character a ClassCastException: java.lang.Character cannot be cast to java.lang.String
java.lang.String 2 true
java.lang.Integer 2 ClassCastException: java.lang.Integer cannot be cast to java.lang.String
java.lang.Long 2 ClassCastException: java.lang.Long cannot be cast to java.lang.String

MultiRegex

Checks if a string matches at least one pattern. Javadoc

Input type: java.lang.String

Example MultiRegex
final MultiRegex function = new MultiRegex(new Pattern[]{Pattern.compile("[a-d]"), Pattern.compile("[0-4]")});
{
  "class" : "MultiRegex",
  "value" : [ {
    "java.util.regex.Pattern" : "[a-d]"
  }, {
    "java.util.regex.Pattern" : "[0-4]"
  } ]
}
g.MultiRegex(
  value=[
    {'java.util.regex.Pattern': '[a-d]'},
    {'java.util.regex.Pattern': '[0-4]'}
  ]
)

Example inputs:

Input Type Input Result
java.lang.String a true
java.lang.String z false
java.lang.String az false
java.lang.Character a ClassCastException: java.lang.Character cannot be cast to java.lang.String
java.lang.String 2 true
java.lang.Integer 2 ClassCastException: java.lang.Integer cannot be cast to java.lang.String
java.lang.Long 2 ClassCastException: java.lang.Long cannot be cast to java.lang.String