Java Code Examples for org.apache.tinkerpop.gremlin.structure.VertexProperty#properties()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.VertexProperty#properties() . 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: DetachedVertexProperty.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
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))));
        }
    }
}
 
Example 2
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator,
                                        final boolean normalize) throws IOException {
    jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES);
    jsonGenerator.writeStartObject();

    final Iterator<Property<Object>> metaProperties = normalize ?
            IteratorUtils.list((Iterator<Property<Object>>) property.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : property.properties();
    while (metaProperties.hasNext()) {
        final Property<Object> metaProperty = metaProperties.next();
        jsonGenerator.writeObjectField(metaProperty.key(), metaProperty.value());
    }

    jsonGenerator.writeEndObject();
}
 
Example 3
Source File: GraphSONSerializersV1d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator,
                                        final SerializerProvider serializerProvider,
                                        final TypeSerializer typeSerializer, final boolean normalize) throws IOException {
    jsonGenerator.writeObjectFieldStart(GraphSONTokens.PROPERTIES);
    if (typeSerializer != null) jsonGenerator.writeStringField(GraphSONTokens.CLASS, HashMap.class.getName());
    final Iterator<Property<Object>> metaProperties = normalize ?
            IteratorUtils.list(( Iterator<Property<Object>>) property.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : property.properties();
    while (metaProperties.hasNext()) {
        final Property<Object> metaProperty = metaProperties.next();
        GraphSONUtil.writeWithType(metaProperty.key(), metaProperty.value(), jsonGenerator, serializerProvider, typeSerializer);
    }
    jsonGenerator.writeEndObject();
}
 
Example 4
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static void writeMetaProperties(final VertexProperty property, final JsonGenerator jsonGenerator,
                                        final boolean normalize) throws IOException {
    jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES);
    jsonGenerator.writeStartObject();

    final Iterator<Property<Object>> metaProperties = normalize ?
            IteratorUtils.list((Iterator<Property<Object>>) property.properties(), Comparators.PROPERTY_COMPARATOR).iterator() : property.properties();
    while (metaProperties.hasNext()) {
        final Property<Object> metaProperty = metaProperties.next();
        jsonGenerator.writeObjectField(metaProperty.key(), metaProperty.value());
    }

    jsonGenerator.writeEndObject();
}
 
Example 5
Source File: AbstractCompatibilityTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
protected void assertVertexProperty(final VertexProperty expected, final VertexProperty actual) {
    assertEquals(expected.id(), actual.id());
    assertEquals(expected.label(), actual.label());

    if (!(getCompatibility() instanceof GraphBinaryCompatibility)) {
        assertEquals(IteratorUtils.count(expected.properties()), IteratorUtils.count(actual.properties()));
        final Iterator<Property> itty = expected.properties();
        while (itty.hasNext()) {
            final Property p = itty.next();
            assertProperty(p, actual.property(p.key()));
        }
    }
}