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 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 |
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 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 |
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 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 |
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 Type | Input | Result |
---|---|---|
java.lang.Integer | -5 | false |
java.lang.Integer | 1 | false |
java.lang.Integer | 5 | true |
java.lang.Integer | 7 | true |
java.lang.Integer | 10 | true |
java.lang.Integer | 20 | false |
java.lang.Long | 7 | ClassCastException: java.lang.Integer cannot be cast to java.lang.Long |
java.lang.String | 7 | ClassCastException: java.lang.Integer cannot be cast to java.lang.String |
null | false |
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 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 |