当前位置: 首页>>代码示例>>Java>>正文


Java Property类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Property的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Property类属于org.apache.tinkerpop.gremlin.structure包,在下文中一共展示了Property类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldSerializeEdgeProperty

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
public void shouldSerializeEdgeProperty() throws Exception {
    final Graph g = TinkerGraph.open();
    final Vertex v1 = g.addVertex();
    final Vertex v2 = g.addVertex();
    final Edge e = v1.addEdge("test", v2);
    e.property("abc", 123);

    final Iterable<Property<Object>> iterable = IteratorUtils.list(e.properties("abc"));
    final String results = SERIALIZER.serializeResponseAsString(ResponseMessage.build(msg).result(iterable).create());

    final JsonNode json = mapper.readTree(results);

    assertNotNull(json);
    assertEquals(msg.getRequestId().toString(), json.get(SerTokens.TOKEN_REQUEST).asText());
    final JsonNode converted = json.get(SerTokens.TOKEN_RESULT).get(SerTokens.TOKEN_DATA);

    assertNotNull(converted);
    assertEquals(1, converted.size());

    final JsonNode propertyAsJson = converted.get(0);
    assertNotNull(propertyAsJson);

    assertEquals(123, propertyAsJson.get("value").asInt());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:GraphSONMessageSerializerV1d0Test.java

示例2: shouldSerializeEdgeProperty

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
public void shouldSerializeEdgeProperty() throws Exception {
    final Graph graph = TinkerGraph.open();
    final Vertex v1 = graph.addVertex();
    final Vertex v2 = graph.addVertex();
    final Edge e = v1.addEdge("test", v2);
    e.property("abc", 123);

    final Iterable<Property<Object>> iterable = IteratorUtils.list(e.properties("abc"));
    final ResponseMessage response = convert(iterable);
    assertCommon(response);

    final List<Map<String, Object>> propertyList = (List<Map<String, Object>>) response.getResult().getData();
    assertEquals(1, propertyList.size());
    assertEquals(123, propertyList.get(0).get("value"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GraphSONMessageSerializerGremlinV1d0Test.java

示例3: find

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的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;
}
 
开发者ID:karthicks,项目名称:gremlin-ogm,代码行数:20,代码来源:ElementGraph.java

示例4: createKeyIndex

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
public void createKeyIndex(final String key) {
    if (null == key)
        throw Graph.Exceptions.argumentCanNotBeNull("key");
    if (key.isEmpty())
        throw new IllegalArgumentException("The key for the index cannot be an empty string");

    if (this.indexedKeys.contains(key))
        return;
    this.indexedKeys.add(key);

    (Vertex.class.isAssignableFrom(this.indexClass) ?
            this.graph.vertices.values().<T>stream() :
            this.graph.edges.values().<T>stream())
            .map(e -> new Object[]{((T) e).property(key), e})
            .filter(a -> ((Property) a[0]).isPresent())
            .forEach(a -> this.put(key, ((Property) a[0]).value(), (T) a[1]));
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:18,代码来源:TinkerIndex.java

示例5: properties

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Override
// THERE ARE TWO MORE COPIES OF THIS CODE IN ELEMENT AND VERTEX
public <T> Iterator<Property<T>> properties(String... propertyKeys) {
    ArrayList<Property<T>> ans = new ArrayList<Property<T>>();

    if (propertyKeys.length == 0) {
    	if (this.properties == null) return Collections.emptyIterator();
    	propertyKeys = this.properties.getPropertyKeys();
    }

    for (String key : propertyKeys) {
        Property<T> prop = property(key);
        if (prop.isPresent()) ans.add(prop);
    }
    return ans.iterator();
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:17,代码来源:BitsyEdge.java

示例6: givenEdgeWithPropertyValueShouldShouldGetPropertyValue

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
public void givenEdgeWithPropertyValueShouldShouldGetPropertyValue() {
    // arrange
    Mockito.when(graph.tx()).thenAnswer(invocation -> transaction);
    Mockito.when(relationship.get(Mockito.eq("id"))).thenAnswer(invocation -> Values.value(1L));
    Mockito.when(relationship.type()).thenAnswer(invocation -> "label");
    Mockito.when(relationship.keys()).thenAnswer(invocation -> Collections.singleton("key1"));
    Mockito.when(relationship.get(Mockito.eq("key1"))).thenAnswer(invocation -> Values.value("value1"));
    Mockito.when(provider.fieldName()).thenAnswer(invocation -> "id");
    ArgumentCaptor<Long> argument = ArgumentCaptor.forClass(Long.class);
    Mockito.when(provider.processIdentifier(argument.capture())).thenAnswer(invocation -> argument.getValue());
    Neo4JEdge edge = new Neo4JEdge(graph, session, provider, outVertex, relationship, inVertex);
    edge.property("p1", 1L);
    // act
    Property<?> result = edge.property("p1");
    // assert
    Assert.assertNotNull("Failed to get property value", result);
    Assert.assertTrue("Property value is not present", result.isPresent());
    Assert.assertEquals("Invalid property key", result.key(), "p1");
    Assert.assertEquals("Invalid property value", result.value(), 1L);
    Assert.assertEquals("Invalid property element", result.element(), edge);
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:23,代码来源:Neo4JEdgeWhileGettingPropertyValueTest.java

示例7: shouldDeterminePropertiesAreNotEqualWhenKeysAreDifferent

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
public void shouldDeterminePropertiesAreNotEqualWhenKeysAreDifferent() {
    final Property mockPropertyA = mock(Property.class);
    final Property mockPropertyB = mock(Property.class);
    final Element mockElement = mock(Element.class);
    when(mockPropertyA.isPresent()).thenReturn(true);
    when(mockPropertyB.isPresent()).thenReturn(true);
    when(mockPropertyA.element()).thenReturn(mockElement);
    when(mockPropertyB.element()).thenReturn(mockElement);
    when(mockPropertyA.key()).thenReturn("k");
    when(mockPropertyB.key()).thenReturn("k1");
    when(mockPropertyA.value()).thenReturn("v");
    when(mockPropertyB.value()).thenReturn("v");

    assertFalse(ElementHelper.areEqual(mockPropertyA, mockPropertyB));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:ElementHelperTest.java

示例8: areEqual

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
/**
 * 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 == a)
        throw Graph.Exceptions.argumentCanNotBeNull("a");
    if (null == b)
        throw Graph.Exceptions.argumentCanNotBeNull("b");

    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());

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:ElementHelper.java

示例9: DetachedVertexProperty

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
protected DetachedVertexProperty(final VertexProperty<V> vertexProperty, final boolean withProperties) {
    super(vertexProperty);
    this.value = vertexProperty.value();
    this.vertex = DetachedFactory.detach(vertexProperty.element(), false);

    // only serialize properties if requested, the graph supports it and there are meta properties present.
    // this prevents unnecessary object creation of a new HashMap which will just be empty.  it will use
    // Collections.emptyMap() by default
    if (withProperties && vertexProperty.graph().features().vertex().supportsMetaProperties()) {
        final Iterator<Property<Object>> propertyIterator = vertexProperty.properties();
        if (propertyIterator.hasNext()) {
            this.properties = new HashMap<>();
            propertyIterator.forEachRemaining(property -> this.properties.put(property.key(), Collections.singletonList(DetachedFactory.detach(property))));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:DetachedVertexProperty.java

示例10: shouldAttachWithGetMethod

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
public void shouldAttachWithGetMethod() {
    // vertex host
    g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(Attachable.Method.get(vertex))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(Attachable.Method.get(vertex)))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(Attachable.Method.get(vertex))))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(Attachable.Method.get(vertex)))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(Attachable.Method.get(vertex))))));

    // graph host
    g.V().forEachRemaining(vertex -> TestHelper.validateEquality(vertex, StarGraph.of(vertex).getStarVertex().attach(Attachable.Method.get(graph))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> TestHelper.validateEquality(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(Attachable.Method.get(graph)))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(Attachable.Method.get(graph))))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> TestHelper.validateEquality(edge, ((Attachable<Edge>) edge).attach(Attachable.Method.get(graph)))));
    g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> TestHelper.validateEquality(property, ((Attachable<Property>) property).attach(Attachable.Method.get(graph))))));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:StarGraphTest.java

示例11: DetachedEdge

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
protected DetachedEdge(final Edge edge, final boolean withProperties) {
    super(edge);
    this.outVertex = DetachedFactory.detach(edge.outVertex(), false);
    this.inVertex = DetachedFactory.detach(edge.inVertex(), false);

    // only serialize properties if requested, the graph supports it and there are meta properties present.
    // this prevents unnecessary object creation of a new HashMap of a new HashMap which will just be empty.
    // it will use Collections.emptyMap() by default
    if (withProperties) {
        final Iterator<Property<Object>> propertyIterator = edge.properties();
        if (propertyIterator.hasNext()) {
            this.properties = new HashMap<>();
            propertyIterator.forEachRemaining(property -> this.properties.put(property.key(), Collections.singletonList(DetachedFactory.detach(property))));
        }
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:DetachedEdge.java

示例12: DetachedPath

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
protected DetachedPath(final Path path, final boolean withProperties) {
    path.forEach((object, labels) -> {
        if (object instanceof DetachedElement || object instanceof DetachedProperty || object instanceof DetachedPath) {
            this.objects.add(object);
            this.labels.add(labels);
        } else if (object instanceof Element) {
            this.objects.add(DetachedFactory.detach((Element) object, withProperties));
            this.labels.add(labels);
        } else if (object instanceof Property) {
            this.objects.add(DetachedFactory.detach((Property) object));
            this.labels.add(labels);
        } else if (object instanceof Path) {
            this.objects.add(DetachedFactory.detach((Path) object, withProperties));
            this.labels.add(labels);
        } else {
            this.objects.add(object);
            this.labels.add(labels);
        }
    });
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:DetachedPath.java

示例13: create

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
public static <V> Function<Attachable<V>, V> create(final Host hostVertexOrGraph) {
    return (Attachable<V> attachable) -> {
        final Object base = attachable.get();
        if (base instanceof Vertex) {
            return hostVertexOrGraph instanceof Graph ?
                    (V) Method.createVertex((Attachable<Vertex>) attachable, (Graph) hostVertexOrGraph) :
                    (V) Method.createVertex((Attachable<Vertex>) attachable, (Vertex) hostVertexOrGraph);
        } else if (base instanceof Edge) {
            return hostVertexOrGraph instanceof Graph ?
                    (V) Method.createEdge((Attachable<Edge>) attachable, (Graph) hostVertexOrGraph) :
                    (V) Method.createEdge((Attachable<Edge>) attachable, (Vertex) hostVertexOrGraph);
        } else if (base instanceof VertexProperty) {
            return hostVertexOrGraph instanceof Graph ?
                    (V) Method.createVertexProperty((Attachable<VertexProperty>) attachable, (Graph) hostVertexOrGraph) :
                    (V) Method.createVertexProperty((Attachable<VertexProperty>) attachable, (Vertex) hostVertexOrGraph);
        } else if (base instanceof Property) {
            return hostVertexOrGraph instanceof Graph ?
                    (V) Method.createProperty((Attachable<Property>) attachable, (Graph) hostVertexOrGraph) :
                    (V) Method.createProperty((Attachable<Property>) attachable, (Vertex) hostVertexOrGraph);
        } else
            throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
    };
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:24,代码来源:Attachable.java

示例14: createProperty

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的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");
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:Attachable.java

示例15: givenPropertyValueShouldAddItToEdge

import org.apache.tinkerpop.gremlin.structure.Property; //导入依赖的package包/类
@Test
public void givenPropertyValueShouldAddItToEdge() {
    // arrange
    Mockito.when(graph.tx()).thenAnswer(invocation -> transaction);
    Mockito.when(relationship.get(Mockito.eq("id"))).thenAnswer(invocation -> Values.value(1L));
    Mockito.when(relationship.type()).thenAnswer(invocation -> "label");
    Mockito.when(relationship.keys()).thenAnswer(invocation -> Collections.singleton("key1"));
    Mockito.when(relationship.get(Mockito.eq("key1"))).thenAnswer(invocation -> Values.value("value1"));
    Mockito.when(provider.fieldName()).thenAnswer(invocation -> "id");
    ArgumentCaptor<Long> argument = ArgumentCaptor.forClass(Long.class);
    Mockito.when(provider.processIdentifier(argument.capture())).thenAnswer(invocation -> argument.getValue());
    Neo4JEdge edge = new Neo4JEdge(graph, session, provider, outVertex, relationship, inVertex);
    Property<?> result = edge.property("p1", 1L);
    // act
    result.remove();
    // assert
    Assert.assertFalse("Failed to remove property from edge", edge.property("p1").isPresent());
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:19,代码来源:Neo4JEdgeWhileRemovingPropertyValueTest.java


注:本文中的org.apache.tinkerpop.gremlin.structure.Property类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。