Search in sources :

Example 1 with TemporalValue

use of org.neo4j.values.storable.TemporalValue in project neo4j by neo4j.

the class TemporalFunction method apply.

@Override
public final AnyValue apply(Context ctx, AnyValue[] input) throws ProcedureException {
    if (input == null || (input.length > 0 && (input[0] == NO_VALUE || input[0] == null))) {
        return NO_VALUE;
    } else if (input.length == 0 || input[0].equals(DEFAULT_TEMPORAL_ARGUMENT_VALUE)) {
        return now(ctx.statementClock(), null, defaultZone);
    } else if (input[0] instanceof TextValue) {
        return parse((TextValue) input[0], defaultZone);
    } else if (input[0] instanceof TemporalValue) {
        return select(input[0], defaultZone);
    } else if (input[0] instanceof MapValue) {
        MapValue map = (MapValue) input[0];
        String timezone = onlyTimezone(map);
        if (timezone != null) {
            return now(ctx.statementClock(), timezone, defaultZone);
        }
        return build(map, defaultZone);
    } else {
        throw new ProcedureException(Status.Procedure.ProcedureCallFailed, "Invalid call signature for " + getClass().getSimpleName() + ": Provided input was " + Arrays.toString(input));
    }
}
Also used : TextValue(org.neo4j.values.storable.TextValue) TemporalValue(org.neo4j.values.storable.TemporalValue) MapValue(org.neo4j.values.virtual.MapValue) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException)

Aggregations

ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)1 TemporalValue (org.neo4j.values.storable.TemporalValue)1 TextValue (org.neo4j.values.storable.TextValue)1 MapValue (org.neo4j.values.virtual.MapValue)1