本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.VertexProperty.property方法的典型用法代码示例。如果您正苦于以下问题:Java VertexProperty.property方法的具体用法?Java VertexProperty.property怎么用?Java VertexProperty.property使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.structure.VertexProperty
的用法示例。
在下文中一共展示了VertexProperty.property方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProperty
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
public static Property createProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
final Property baseProperty = attachableProperty.get();
final Element baseElement = baseProperty.element();
if (baseElement instanceof Vertex) {
return Method.createVertexProperty((Attachable) attachableProperty, hostGraph);
} else if (baseElement instanceof Edge) {
final Iterator<Edge> edgeIterator = hostGraph.edges(baseElement.id());
if (edgeIterator.hasNext())
return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
throw new IllegalStateException("Could not find edge to create the attachable property on");
} else { // vertex property
final Iterator<Vertex> vertexIterator = hostGraph.vertices(((VertexProperty) baseElement).element().id());
if (vertexIterator.hasNext()) {
final Vertex vertex = vertexIterator.next();
final Iterator<VertexProperty<Object>> vertexPropertyIterator = vertex.properties(((VertexProperty) baseElement).key());
while (vertexPropertyIterator.hasNext()) {
final VertexProperty<Object> vp = vertexPropertyIterator.next();
if (ElementHelper.areEqual(vp, baseElement))
return vp.property(baseProperty.key(), baseProperty.value());
}
}
throw new IllegalStateException("Could not find vertex property to create the attachable property on");
}
}
示例2: testAllFiveKinds
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
/**
* Make sure we can find all five kinds of properties:
* <p>
* <pre>
* Edge -> Property
* Vertex -> VertexProperty(single/set)
* Vertex -> VertexProperty(list)
* VertexProperty(single/set) -> Property
* VertexProperty(list) -> Property
* </pre>
* </p>
*/
public void testAllFiveKinds() {
final BlazeVertex a = graph.addVertex(T.id, "a");
final BlazeVertex b = graph.addVertex(T.id, "b");
final BlazeEdge e = graph.addEdge(a, b, Edge.DEFAULT_LABEL, T.id, "e");
final Property<String> ep = e.property("ep", "foo 1");
final VertexProperty<String> vps = a.property(Cardinality.single, "vps", "foo 2");
final VertexProperty<String> vpl = a.property(Cardinality.list, "vpl", "foo 3");
final Property<String> vpsp = vps.property("vpsp", "foo 4");
final Property<String> vplp = vpl.property("vplp", "foo 5");
graph.commit();
final Map<String,Property<String>> expected =
new HashMap<String,Property<String>>() {{
put("foo 1", ep);
put("foo 2", vps);
put("foo 3", vpl);
put("foo 4", vpsp);
put("foo 5", vplp);
}};
log.debug(() -> "\n"+graph.dumpStore());
final List<Property<String>> results =
graph.<String>search("foo", Match.ANY).collect();
log.debug(() -> results.stream());
assertEquals(5, results.size());
results.stream().forEach(p -> {
assertEquals(expected.get(p.value()), p);
});
}
示例3: shouldNotGenerateNodesAndRelationshipsForNoMultiPropertiesNoMetaProperties
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES, supported = false)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES, supported = false)
public void shouldNotGenerateNodesAndRelationshipsForNoMultiPropertiesNoMetaProperties() {
graph.tx().readWrite();
tryCommit(graph, graph -> validateCounts(0, 0, 0, 0));
Vertex vertex = graph.addVertex(T.label, "person");
tryCommit(graph, graph -> validateCounts(1, 0, 1, 0));
vertex.property("name", "marko");
assertEquals("marko", vertex.value("name"));
tryCommit(graph, graph -> validateCounts(1, 0, 1, 0));
vertex.property("name", "okram");
tryCommit(graph, g -> {
validateCounts(1, 0, 1, 0);
assertEquals("okram", vertex.value("name"));
});
VertexProperty vertexProperty = vertex.property("name");
tryCommit(graph, graph -> {
assertTrue(vertexProperty.isPresent());
assertEquals("name", vertexProperty.key());
assertEquals("okram", vertexProperty.value());
validateCounts(1, 0, 1, 0);
});
try {
vertexProperty.property("acl", "private");
} catch (UnsupportedOperationException e) {
assertEquals(VertexProperty.Exceptions.metaPropertiesNotSupported().getMessage(), e.getMessage());
}
}
示例4: shouldNotGenerateNodesAndRelationshipsForMultiPropertiesWithSingle
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
public void shouldNotGenerateNodesAndRelationshipsForMultiPropertiesWithSingle() {
graph.tx().readWrite();
tryCommit(graph, graph -> validateCounts(0, 0, 0, 0));
Vertex vertex = graph.addVertex(T.label, "person");
tryCommit(graph, graph -> validateCounts(1, 0, 1, 0));
vertex.property(VertexProperty.Cardinality.list, "name", "marko");
assertEquals("marko", vertex.value("name"));
tryCommit(graph, graph -> validateCounts(1, 0, 1, 0));
vertex.property(VertexProperty.Cardinality.single, "name", "okram");
tryCommit(graph, graph -> {
validateCounts(1, 0, 1, 0);
assertEquals("okram", vertex.value("name"));
});
VertexProperty vertexProperty = vertex.property("name");
tryCommit(graph, graph -> {
assertTrue(vertexProperty.isPresent());
assertEquals("name", vertexProperty.key());
assertEquals("okram", vertexProperty.value());
validateCounts(1, 0, 1, 0);
});
// now make it a meta property (and thus, force node/relationship creation)
vertexProperty.property("acl", "private");
tryCommit(graph, graph -> {
assertEquals("private", vertexProperty.value("acl"));
validateCounts(1, 0, 2, 1);
});
}