InRange

See javadoc - uk.gov.gchq.koryphe.impl.predicate.range.InRange

Available since Koryphe version 1.1.0

Checks if a comparable is within a provided range

Examples

In long range 5 to 10

Java
JSON
Full JSON
Python
final InRange function = new InRange.Builder<Long>()
        .start(5L)
        .end(10L)
        .build();
{
  "class" : "InRange",
  "start" : {
    "Long" : 5
  },
  "end" : {
    "Long" : 10
  }
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InRange",
  "start" : {
    "java.lang.Long" : 5
  },
  "end" : {
    "java.lang.Long" : 10
  }
}
g.InRange( 
  start={'java.lang.Long': 5}, 
  end={'java.lang.Long': 10} 
)

Input type:

java.lang.Comparable

Example inputs:

Input TypeInputResult
java.lang.Long-5false
java.lang.Long1false
java.lang.Long5true
java.lang.Long7true
java.lang.Long10true
java.lang.Long20false
java.lang.Integer7ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String7ClassCastException: java.lang.Long cannot be cast to java.lang.String
nullfalse

In long range 5 to 10 exclusive

Java
JSON
Full JSON
Python
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
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InRange",
  "start" : {
    "java.lang.Long" : 5
  },
  "end" : {
    "java.lang.Long" : 10
  },
  "startInclusive" : false,
  "endInclusive" : false
}
g.InRange( 
  start={'java.lang.Long': 5}, 
  end={'java.lang.Long': 10}, 
  start_inclusive=False, 
  end_inclusive=False 
)

Input type:

java.lang.Comparable

Example inputs:

Input TypeInputResult
java.lang.Long-5false
java.lang.Long1false
java.lang.Long5false
java.lang.Long7true
java.lang.Long10false
java.lang.Long20false
java.lang.Integer7ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String7ClassCastException: java.lang.Long cannot be cast to java.lang.String
nullfalse

In long range less than 10

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

Java
JSON
Full JSON
Python
final InRange function = new InRange.Builder<Long>()
        .end(10L)
        .endInclusive(false)
        .build();
{
  "class" : "InRange",
  "end" : {
    "Long" : 10
  },
  "endInclusive" : false
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InRange",
  "end" : {
    "java.lang.Long" : 10
  },
  "endInclusive" : false
}
g.InRange( 
  end={'java.lang.Long': 10}, 
  end_inclusive=False 
)

Input type:

java.lang.Comparable

Example inputs:

Input TypeInputResult
java.lang.Long-5true
java.lang.Long1true
java.lang.Long5true
java.lang.Long7true
java.lang.Long10false
java.lang.Long20false
java.lang.Integer7ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
java.lang.String7ClassCastException: java.lang.Long cannot be cast to java.lang.String
nullfalse

In integer range 5 to 10

Java
JSON
Full JSON
Python
final InRange function = new InRange.Builder<Integer>()
        .start(5)
        .end(10)
        .build();
{
  "class" : "InRange",
  "start" : 5,
  "end" : 10
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InRange",
  "start" : 5,
  "end" : 10
}
g.InRange( 
  start=5, 
  end=10 
)

Input type:

java.lang.Comparable

Example inputs:

Input TypeInputResult
java.lang.Integer-5false
java.lang.Integer1false
java.lang.Integer5true
java.lang.Integer7true
java.lang.Integer10true
java.lang.Integer20false
java.lang.Long7ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
java.lang.String7ClassCastException: java.lang.Integer cannot be cast to java.lang.String
nullfalse

In string range b to d

Java
JSON
Full JSON
Python
final InRange function = new InRange.Builder<String>()
        .start("B")
        .end("D")
        .build();
{
  "class" : "InRange",
  "start" : "B",
  "end" : "D"
}
{
  "class" : "uk.gov.gchq.koryphe.impl.predicate.range.InRange",
  "start" : "B",
  "end" : "D"
}
g.InRange( 
  start="B", 
  end="D" 
)

Input type:

java.lang.Comparable

Example inputs:

Input TypeInputResult
java.lang.StringAfalse
java.lang.StringBtrue
java.lang.StringCtrue
java.lang.StringDtrue
java.lang.Stringcfalse
java.lang.Integer1ClassCastException: java.lang.String cannot be cast to java.lang.Integer
nullfalse

results matching ""

    No results matching ""