Search in sources :

Example 1 with InternalElement

use of org.janusgraph.graphdb.internal.InternalElement in project janusgraph by JanusGraph.

the class PredicateCondition method evaluate.

@Override
public boolean evaluate(E element) {
    RelationType type;
    if (key instanceof String) {
        type = ((InternalElement) element).tx().getRelationType((String) key);
        if (type == null)
            return satisfiesCondition(null);
    } else {
        type = (RelationType) key;
    }
    Preconditions.checkNotNull(type);
    if (type.isPropertyKey()) {
        Iterator<Object> iterator = ElementHelper.getValues(element, (PropertyKey) type).iterator();
        if (iterator.hasNext()) {
            while (iterator.hasNext()) {
                if (satisfiesCondition(iterator.next()))
                    return true;
            }
            return false;
        }
        return satisfiesCondition(null);
    } else {
        assert ((InternalRelationType) type).multiplicity().isUnique(Direction.OUT);
        return satisfiesCondition(element.value(type.name()));
    }
}
Also used : RelationType(org.janusgraph.core.RelationType) InternalRelationType(org.janusgraph.graphdb.internal.InternalRelationType) InternalElement(org.janusgraph.graphdb.internal.InternalElement) PropertyKey(org.janusgraph.core.PropertyKey)

Aggregations

PropertyKey (org.janusgraph.core.PropertyKey)1 RelationType (org.janusgraph.core.RelationType)1 InternalElement (org.janusgraph.graphdb.internal.InternalElement)1 InternalRelationType (org.janusgraph.graphdb.internal.InternalRelationType)1