Java Code Examples for org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty#build()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty#build() . 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: GryoSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public <I extends InputShim> Vertex read(final KryoShim<I, ?> kryo, final I input, final Class<Vertex> vertexClass) {
    final DetachedVertex.Builder builder = DetachedVertex.build();
    builder.setId(kryo.readClassAndObject(input));
    builder.setLabel(input.readString());

    while(input.readBoolean()) {
        final DetachedVertexProperty.Builder vpBuilder = DetachedVertexProperty.build();
        vpBuilder.setId(kryo.readClassAndObject(input));
        vpBuilder.setLabel(input.readString());
        vpBuilder.setValue(kryo.readClassAndObject(input));

        while(input.readBoolean()) {
            vpBuilder.addProperty(new DetachedProperty<>(input.readString(), kryo.readClassAndObject(input)));
        }

        builder.addProperty(vpBuilder.create());
    }

    return builder.create();
}
 
Example 2
Source File: GryoSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public <I extends InputShim> VertexProperty read(final KryoShim<I, ?> kryo, final I input, final Class<VertexProperty> vertexPropertyClass) {
   final DetachedVertexProperty.Builder vpBuilder = DetachedVertexProperty.build();
    vpBuilder.setId(kryo.readClassAndObject(input));
    vpBuilder.setLabel(input.readString());
    vpBuilder.setValue(kryo.readClassAndObject(input));

    final DetachedVertex.Builder host = DetachedVertex.build();
    host.setId(kryo.readClassAndObject(input));
    host.setLabel(input.readString());
    vpBuilder.setV(host.create());

    while(input.readBoolean()) {
        vpBuilder.addProperty(new DetachedProperty<>(input.readString(), kryo.readClassAndObject(input)));
    }

    return vpBuilder.create();
}
 
Example 3
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            vp.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            vp.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            vp.setValue(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                final String key = jsonParser.getCurrentName();
                jsonParser.nextToken();
                final Object val = deserializationContext.readValue(jsonParser, Object.class);
                vp.addProperty(new DetachedProperty(key, val));
            }
        }
    }

    return vp.create();
}
 
Example 4
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public VertexProperty deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertexProperty.Builder vp = DetachedVertexProperty.build();

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            vp.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            vp.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.VALUE)) {
            jsonParser.nextToken();
            vp.setValue(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                final String key = jsonParser.getCurrentName();
                jsonParser.nextToken();
                final Object val = deserializationContext.readValue(jsonParser, Object.class);
                vp.addProperty(new DetachedProperty(key, val));
            }
        }
    }

    return vp.create();
}