本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.hasLabel方法的典型用法代码示例。如果您正苦于以下问题:Java GraphTraversal.hasLabel方法的具体用法?Java GraphTraversal.hasLabel怎么用?Java GraphTraversal.hasLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
的用法示例。
在下文中一共展示了GraphTraversal.hasLabel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
* Find the given element using it's id, if it has one, or all of it's properties.
*/
protected <E extends Element> GraphTraversal find(E element) {
GraphTraversal traversal = g.V();
if (element.id() != null) {
traversal = traversal.hasId(element.id());
} else {
traversal = traversal.hasLabel(element.label());
Object[] properties = Properties.id(element);
if (properties == null || properties.length == 0) {
properties = Properties.all(element);
}
for (Property property : list(properties)) {
traversal = traversal.has(property.key(), property.value());
}
}
return traversal;
}
示例2: apply
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
@SneakyThrows
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
traversal.hasLabel(element.label());
List<Field> fields;
if (keyType != null) {
if (is(keyType, PrimaryKey.class)) {
fields = primaryKeyFields(element);
} else if (is(keyType, OrderingKey.class)) {
fields = orderingKeyFields(element);
} else {
throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions
.invalidAnnotationType(keyType);
}
} else {
fields = keyFields(element);
}
for (Field field : fields) {
String key = propertyKey(field);
Object value = propertyValue(field, element);
if (isMissing(value)) {
throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions.requiredKeysMissing(
element.getClass(), key);
}
traversal.has(key, value);
}
return traversal;
}
示例3: matchProperty
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
private static GraphTraversal<?, ?> matchProperty(final GraphTraversal<?, ?> traversal, final String propertyName,
final PropertyType type, final Node object) {
switch (propertyName) {
case "id":
return object.isConcrete()
? traversal.hasId(object.getLiteralValue())
: traversal.id().as(object.getName());
case "label":
return object.isConcrete()
? traversal.hasLabel(object.getLiteralValue().toString())
: traversal.label().as(object.getName());
case "key":
return object.isConcrete()
? traversal.hasKey(object.getLiteralValue().toString())
: traversal.key().as(object.getName());
case "value":
return object.isConcrete()
? traversal.hasValue(object.getLiteralValue().toString())
: traversal.value().as(object.getName());
default:
if (type.equals(PropertyType.PROPERTY)) {
return traversal.properties(propertyName).as(object.getName());
} else {
return object.isConcrete()
? traversal.values(propertyName).is(object.getLiteralValue())
: traversal.values(propertyName).as(object.getName());
}
}
}
示例4: apply
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
return traversal.hasLabel(label);
}