Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper#addHasContainer()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper#addHasContainer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their value.
 *
 * @param value       the value of the {@link Element}
 * @param otherValues additional values of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 */
public default GraphTraversal<S, E> hasValue(final Object value, final Object... otherValues) {
    if (value instanceof P)
        return this.hasValue((P) value);
    else {
        final List<Object> values = new ArrayList<>();
        if (value instanceof Object[]) {
            Collections.addAll(values, (Object[]) value);
        } else
            values.add(value);
        for (final Object v : otherValues) {
            if (v instanceof Object[]) {
                Collections.addAll(values, (Object[]) v);
            } else
                values.add(v);
        }
        this.asAdmin().getBytecode().addStep(Symbols.hasValue, values.toArray());
        return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.value.getAccessor(), values.size() == 1 ? P.eq(values.get(0)) : P.within(values)));
    }
}
 
Example 2
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param propertyKey the key of the property to filter on
 * @param value       the value to compare the property value to for equality
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final String propertyKey, final Object value) {
    if (value instanceof P)
        return this.has(propertyKey, (P) value);
    else if (value instanceof Traversal)
        return this.has(propertyKey, (Traversal) value);
    else {
        this.asAdmin().getBytecode().addStep(Symbols.has, propertyKey, value);
        return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, P.eq(value)));
    }
}
 
Example 3
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param accessor the {@link T} accessor of the property to filter on
 * @param value    the value to compare the accessor value to for equality
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final T accessor, final Object value) {
    if (value instanceof P)
        return this.has(accessor, (P) value);
    else if (value instanceof Traversal)
        return this.has(accessor, (Traversal) value);
    else {
        this.asAdmin().getBytecode().addStep(Symbols.has, accessor, value);
        return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(accessor.getAccessor(), P.eq(value)));
    }
}
 
Example 4
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their identifier.
 *
 * @param id       the identifier of the {@link Element}
 * @param otherIds additional identifiers of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.2
 */
public default GraphTraversal<S, E> hasId(final Object id, final Object... otherIds) {
    if (id instanceof P) {
        return this.hasId((P) id);
    }
    else {
        Object[] ids;
        if (id instanceof Object[]) {
            ids = (Object[]) id;
        } else {
            ids = new Object[] {id};
        }
        int size = ids.length;
        int capacity = size;
        for (final Object i : otherIds) {
            if (i.getClass().isArray()) {
                final Object[] tmp = (Object[]) i;
                int newLength = size + tmp.length;
                if (capacity < newLength) {
                    ids = Arrays.copyOf(ids, capacity = size + tmp.length);
                }
                System.arraycopy(tmp, 0, ids, size, tmp.length);
                size = newLength;
            } else {
                if (capacity == size) {
                    ids = Arrays.copyOf(ids, capacity = size * 2);
                }
                ids[size++] = i;
            }
        }
        if (capacity > size) {
            ids = Arrays.copyOf(ids, size);
        }
        this.asAdmin().getBytecode().addStep(Symbols.hasId, ids);
        return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.id.getAccessor(), ids.length == 1 ? P.eq(ids[0]) : P.within(ids)));
    }
}
 
Example 5
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 3 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their label.
 *
 * @param label       the label of the {@link Element}
 * @param otherLabels additional labels of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.2
 */
public default GraphTraversal<S, E> hasLabel(final String label, final String... otherLabels) {
    final String[] labels = new String[otherLabels.length + 1];
    labels[0] = label;
    System.arraycopy(otherLabels, 0, labels, 1, otherLabels.length);
    this.asAdmin().getBytecode().addStep(Symbols.hasLabel, labels);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), labels.length == 1 ? P.eq(labels[0]) : P.within(labels)));
}
 
Example 6
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 3 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their key.
 *
 * @param label       the key of the {@link Element}
 * @param otherLabels additional key of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.2
 */
public default GraphTraversal<S, E> hasKey(final String label, final String... otherLabels) {
    final String[] labels = new String[otherLabels.length + 1];
    labels[0] = label;
    System.arraycopy(otherLabels, 0, labels, 1, otherLabels.length);
    this.asAdmin().getBytecode().addStep(Symbols.hasKey, labels);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.key.getAccessor(), labels.length == 1 ? P.eq(labels[0]) : P.within(labels)));
}
 
Example 7
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param propertyKey the key of the property to filter on
 * @param predicate   the filter to apply to the key's value
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final String propertyKey, final P<?> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.has, propertyKey, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, predicate));
}
 
Example 8
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param accessor  the {@link T} accessor of the property to filter on
 * @param predicate the filter to apply to the key's value
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final T accessor, final P<?> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.has, accessor, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(accessor.getAccessor(), predicate));
}
 
Example 9
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param label       the label of the {@link Element}
 * @param propertyKey the key of the property to filter on
 * @param predicate   the filter to apply to the key's value
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final String label, final String propertyKey, final P<?> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.has, label, propertyKey, predicate);
    TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), P.eq(label)));
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, predicate));
}
 
Example 10
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their properties.
 *
 * @param label       the label of the {@link Element}
 * @param propertyKey the key of the property to filter on
 * @param value       the value to compare the accessor value to for equality
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.0.0-incubating
 */
public default GraphTraversal<S, E> has(final String label, final String propertyKey, final Object value) {
    this.asAdmin().getBytecode().addStep(Symbols.has, label, propertyKey, value);
    TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), P.eq(label)));
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(propertyKey, value instanceof P ? (P) value : P.eq(value)));
}
 
Example 11
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their label.
 *
 * @param predicate the filter to apply to the label of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.4
 */
public default GraphTraversal<S, E> hasLabel(final P<String> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.hasLabel, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.label.getAccessor(), predicate));
}
 
Example 12
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their identifier.
 *
 * @param predicate the filter to apply to the identifier of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.4
 */
public default GraphTraversal<S, E> hasId(final P<Object> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.hasId, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.id.getAccessor(), predicate));
}
 
Example 13
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their key.
 *
 * @param predicate the filter to apply to the key of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.4
 */
public default GraphTraversal<S, E> hasKey(final P<String> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.hasKey, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.key.getAccessor(), predicate));
}
 
Example 14
Source File: GraphTraversal.java    From tinkerpop with Apache License 2.0 2 votes vote down vote up
/**
 * Filters vertices, edges and vertex properties based on their value.
 *
 * @param predicate the filter to apply to the value of the {@link Element}
 * @return the traversal with an appended {@link HasStep}
 * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#has-step" target="_blank">Reference Documentation - Has Step</a>
 * @since 3.2.4
 */
public default GraphTraversal<S, E> hasValue(final P<Object> predicate) {
    this.asAdmin().getBytecode().addStep(Symbols.hasValue, predicate);
    return TraversalHelper.addHasContainer(this.asAdmin(), new HasContainer(T.value.getAccessor(), predicate));
}