Search in sources :

Example 1 with CalledFromGeneratedCode

use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.

the class CypherBoolean method in.

@CalledFromGeneratedCode
public static Value in(AnyValue lhs, AnyValue rhs) {
    assert rhs != NO_VALUE;
    ListValue anyValues = CypherFunctions.asList(rhs);
    boolean seenUndefined = false;
    for (AnyValue value : anyValues) {
        switch(lhs.ternaryEquals(value)) {
            case TRUE:
                return Values.TRUE;
            case UNDEFINED:
                seenUndefined = true;
            case FALSE:
                break;
            default:
                throw new IllegalStateException("Unknown state");
        }
    }
    return seenUndefined ? NO_VALUE : Values.FALSE;
}
Also used : ListValue(org.neo4j.values.virtual.ListValue) AnyValue(org.neo4j.values.AnyValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 2 with CalledFromGeneratedCode

use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.

the class CypherFunctions method last.

@CalledFromGeneratedCode
public static AnyValue last(AnyValue container) {
    assert container != NO_VALUE : "NO_VALUE checks need to happen outside this call";
    if (container instanceof SequenceValue) {
        SequenceValue sequence = (SequenceValue) container;
        int length = sequence.length();
        if (length == 0) {
            return NO_VALUE;
        }
        return sequence.value(length - 1);
    } else {
        throw new CypherTypeException(format("Invalid input for function 'last()': Expected %s to be a list", container));
    }
}
Also used : SequenceValue(org.neo4j.values.SequenceValue) CypherTypeException(org.neo4j.exceptions.CypherTypeException) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 3 with CalledFromGeneratedCode

use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.

the class PathValueBuilder method addMultipleIncoming.

/**
 * Adds multiple incoming relationships to the path
 *
 * @param relationships the incoming relationships to add
 * @param target the final target node of the path
 */
@CalledFromGeneratedCode
public void addMultipleIncoming(ListValue relationships, NodeValue target) {
    if (relationships.isEmpty()) {
        // nothing to do here
        return;
    }
    int i;
    for (i = 0; i < relationships.size() - 1; i++) {
        AnyValue value = relationships.value(i);
        if (notNoValue(value)) {
            RelationshipValue relationship = (RelationshipValue) value;
            nodes.add(relationship.startNode());
            rels.add(relationship);
        }
    }
    AnyValue last = relationships.value(i);
    if (notNoValue(last)) {
        rels.add((RelationshipValue) last);
        nodes.add(target);
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 4 with CalledFromGeneratedCode

use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.

the class PathValueBuilder method addMultipleOutgoing.

/**
 * Adds multiple outgoing relationships to the path
 *
 * @param relationships the outgoing relationships to add
 */
@CalledFromGeneratedCode
public void addMultipleOutgoing(ListValue relationships) {
    for (AnyValue value : relationships) {
        if (notNoValue(value)) {
            // we know these relationships have already loaded start and end relationship
            // so we should not use CypherFunctions::[start,end]Node to look them up
            RelationshipValue relationship = (RelationshipValue) value;
            nodes.add(relationship.endNode());
            rels.add(relationship);
        }
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Example 5 with CalledFromGeneratedCode

use of org.neo4j.util.CalledFromGeneratedCode in project neo4j by neo4j.

the class PathValueBuilder method addMultipleIncoming.

/**
 * Adds multiple incoming relationships to the path
 *
 * @param relationships the incoming relationships to add
 */
@CalledFromGeneratedCode
public void addMultipleIncoming(ListValue relationships) {
    for (AnyValue value : relationships) {
        if (notNoValue(value)) {
            // we know these relationships have already loaded start and end relationship
            // so we should not use CypherFunctions::[start,end]Node to look them up
            RelationshipValue relationship = (RelationshipValue) value;
            nodes.add(relationship.startNode());
            rels.add(relationship);
        }
    }
}
Also used : AnyValue(org.neo4j.values.AnyValue) RelationshipValue(org.neo4j.values.virtual.RelationshipValue) CalledFromGeneratedCode(org.neo4j.util.CalledFromGeneratedCode)

Aggregations

CalledFromGeneratedCode (org.neo4j.util.CalledFromGeneratedCode)8 AnyValue (org.neo4j.values.AnyValue)7 RelationshipValue (org.neo4j.values.virtual.RelationshipValue)6 ListValue (org.neo4j.values.virtual.ListValue)2 CypherTypeException (org.neo4j.exceptions.CypherTypeException)1 SequenceValue (org.neo4j.values.SequenceValue)1