use of org.neo4j.values.storable.NumberValue in project neo4j by neo4j.
the class CypherFunctions method listAccess.
private static AnyValue listAccess(SequenceValue container, AnyValue index) {
NumberValue number = asNumberValue(index, () -> "Cannot access a list '" + container.toString() + "' using a non-number index, got " + index.toString());
if (!(number instanceof IntegralValue)) {
throw new CypherTypeException(format("Cannot access a list using an non-integer number index, got %s", number), null);
}
long idx = number.longValue();
if (idx > Integer.MAX_VALUE || idx < Integer.MIN_VALUE) {
throw new InvalidArgumentException(format("Cannot index a list using a value greater than %d or lesser than %d, got %d", Integer.MAX_VALUE, Integer.MIN_VALUE, idx));
}
if (idx < 0) {
idx = container.length() + idx;
}
if (idx >= container.length() || idx < 0) {
return NO_VALUE;
}
return container.value((int) idx);
}
Aggregations