本文整理了Java中org.apache.tinkerpop.gremlin.structure.Property.element()
方法的一些代码示例,展示了Property.element()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.element()
方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Property
类名称:Property
方法名:element
[英]Get the element that this property is associated with.
[中]获取与此属性关联的元素。
代码示例来源:origin: apache/tinkerpop
/**
* Extracts the {@link Vertex} that is holding the specified object.
*
* @throws IllegalStateException if the object is not a graph element type
*/
public static Vertex getHostingVertex(final Object object) {
Object obj = object;
while (true) {
if (obj instanceof Vertex)
return (Vertex) obj;
else if (obj instanceof Edge)
return ((Edge) obj).outVertex();
else if (obj instanceof Property)
obj = ((Property) obj).element();
else
throw new IllegalStateException("The host of the object is unknown: " + obj.toString() + ':' + obj.getClass().getCanonicalName());
}
}
}
代码示例来源:origin: apache/tinkerpop
public ReferenceProperty(final Property<V> property) {
this.element = null == property.element() ? null : ReferenceFactory.detach(property.element());
this.key = property.key();
this.value = property.value();
}
代码示例来源:origin: apache/tinkerpop
protected DetachedProperty(final Property<V> property) {
this.key = property.key();
this.value = property.value();
this.element = DetachedFactory.detach(property.element(), false);
}
代码示例来源:origin: apache/tinkerpop
@Override
public Element element() {
final Element element = this.property.element();
if (element instanceof Vertex)
return new ComputerVertex((Vertex) element);
else if (element instanceof Edge)
return new ComputerEdge((Edge) element);
else
return new ComputerVertexProperty((VertexProperty) element);
}
代码示例来源:origin: apache/tinkerpop
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Property property) {
output.writeString(property.key());
kryo.writeClassAndObject(output, property.value());
kryo.writeClassAndObject(output, property.element().id());
output.writeString(property.element().label());
}
代码示例来源:origin: apache/tinkerpop
public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
final Property baseProperty = attachableProperty.get();
final Element propertyElement = attachableProperty.get().element();
if (propertyElement instanceof Vertex) {
return (Optional) Method.getVertexProperty((Attachable) attachableProperty, hostVertex);
while (vertexPropertyIterator.hasNext()) {
final VertexProperty vertexProperty = vertexPropertyIterator.next();
if (ElementHelper.areEqual(vertexProperty, baseProperty.element())) {
final Property property = vertexProperty.property(baseProperty.key());
if (property.isPresent() && property.value().equals(baseProperty.value()))
代码示例来源:origin: apache/tinkerpop
public static void validatePropertyEquality(final Property originalProperty, final Property otherProperty) {
assertEquals(originalProperty, otherProperty);
assertEquals(otherProperty, originalProperty);
if (originalProperty.isPresent()) {
assertEquals(originalProperty.key(), otherProperty.key());
assertEquals(originalProperty.value(), otherProperty.value());
assertEquals(originalProperty.element(), otherProperty.element());
}
}
代码示例来源:origin: apache/tinkerpop
public static Property createProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
final Property baseProperty = attachableProperty.get();
final Element baseElement = baseProperty.element();
if (baseElement instanceof Vertex) {
return Method.createVertexProperty((Attachable) attachableProperty, hostVertex);
} else if (baseElement instanceof Edge) {
final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
if (edgeIterator.hasNext())
return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
throw new IllegalStateException("Could not find edge to create the property on");
} else { // vertex property
final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.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");
}
}
}
代码示例来源:origin: apache/tinkerpop
public static Optional<Property> getProperty(final Attachable<Property> attachableProperty, final Graph hostGraph) {
final Property baseProperty = attachableProperty.get();
final Element propertyElement = attachableProperty.get().element();
if (propertyElement instanceof Vertex) {
return (Optional) Method.getVertexProperty((Attachable) attachableProperty, hostGraph);
while (vertexPropertyIterator.hasNext()) {
final VertexProperty vertexProperty = vertexPropertyIterator.next();
if (ElementHelper.areEqual(vertexProperty, baseProperty.element())) {
final Property property = vertexProperty.property(baseProperty.key());
if (property.isPresent() && property.value().equals(baseProperty.value()))
代码示例来源:origin: apache/tinkerpop
/**
* A standard method for determining if two {@link org.apache.tinkerpop.gremlin.structure.Property} objects are equal. This method should be used by any
* {@link Object#equals(Object)} implementation to ensure consistent behavior.
*
* @param a the first {@link org.apache.tinkerpop.gremlin.structure.Property}
* @param b the second {@link org.apache.tinkerpop.gremlin.structure.Property}
* @return true if equal and false otherwise
*/
public static boolean areEqual(final Property a, final Object b) {
if (null == b || null == a)
return false;
if (a == b)
return true;
if (!(b instanceof Property))
return false;
if (!a.isPresent() && !((Property) b).isPresent())
return true;
if (!a.isPresent() && ((Property) b).isPresent() || a.isPresent() && !((Property) b).isPresent())
return false;
return a.key().equals(((Property) b).key()) && a.value().equals(((Property) b).value()) && areEqual(a.element(), ((Property) b).element());
}
代码示例来源:origin: apache/tinkerpop
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");
}
}
代码示例来源:origin: apache/tinkerpop
final EventStrategy eventStrategy = getTraversal().getStrategies().getStrategy(EventStrategy.class).get();
final Event.ElementPropertyEvent removeEvent;
if (toRemove.element() instanceof Edge)
removeEvent = new Event.EdgePropertyRemovedEvent(eventStrategy.detach((Edge) toRemove.element()), eventStrategy.detach(toRemove));
else if (toRemove.element() instanceof VertexProperty)
removeEvent = new Event.VertexPropertyPropertyRemovedEvent(eventStrategy.detach((VertexProperty) toRemove.element()), eventStrategy.detach(toRemove));
else
throw new IllegalStateException("The incoming object is not removable: " + s);
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
public ReferenceProperty(final Property<V> property) {
this.element = null == property.element() ? null : ReferenceFactory.detach(property.element());
this.key = property.key();
this.value = property.value();
}
代码示例来源:origin: apache/tinkerpop
assertEquals(2, IteratorUtils.count(v.properties()));
assertVertexEdgeCounts(graph, 1, 0);
assertEquals(v.property("name"), v.property("name").property("acl", "public").element());
assertEquals(v.property("age"), v.property("age").property("acl", "private").element());
});
代码示例来源:origin: com.orientechnologies/orientdb-gremlin
public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
Iterator<? extends Property<V>> properties = super.properties(propertyKeys);
return StreamUtils.asStream(properties).filter(p -> !INTERNAL_FIELDS.contains(p.key())).filter(p -> !p.key().startsWith("out_"))
.filter(p -> !p.key().startsWith("in_")).filter(p -> !p.key().startsWith("_meta_"))
.map(p -> (VertexProperty<V>) new OrientVertexProperty<>(p.key(), p.value(), (OrientVertex) p.element())).iterator();
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
@Override
public Element element() {
final Element element = this.property.element();
if (element instanceof Vertex)
return new ComputerVertex((Vertex) element);
else if (element instanceof Edge)
return new ComputerEdge((Edge) element);
else
return new ComputerVertexProperty((VertexProperty) element);
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
protected DetachedProperty(final Property<V> property) {
this.key = property.key();
this.value = property.value();
this.element = DetachedFactory.detach(property.element(), false);
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
@Override
public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final Property property) {
output.writeString(property.key());
kryo.writeClassAndObject(output, property.value());
kryo.writeClassAndObject(output, property.element().id());
output.writeString(property.element().label());
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-core
public static Property createProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
final Property baseProperty = attachableProperty.get();
final Element baseElement = baseProperty.element();
if (baseElement instanceof Vertex) {
return Method.createVertexProperty((Attachable) attachableProperty, hostVertex);
} else if (baseElement instanceof Edge) {
final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
if (edgeIterator.hasNext())
return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
throw new IllegalStateException("Could not find edge to create the property on");
} else { // vertex property
final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.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");
}
}
}
代码示例来源:origin: org.apache.tinkerpop/gremlin-test
public static void validatePropertyEquality(final Property originalProperty, final Property otherProperty) {
assertEquals(originalProperty, otherProperty);
assertEquals(otherProperty, originalProperty);
if (originalProperty.isPresent()) {
assertEquals(originalProperty.key(), otherProperty.key());
assertEquals(originalProperty.value(), otherProperty.value());
assertEquals(originalProperty.element(), otherProperty.element());
}
}
内容来源于网络,如有侵权,请联系作者删除!