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

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex#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> Edge read(final KryoShim<I, ?> kryo, final I input, final Class<Edge> edgeClass) {
    final DetachedEdge.Builder builder = DetachedEdge.build();
    builder.setId(kryo.readClassAndObject(input));
    builder.setLabel(input.readString());

    final DetachedVertex.Builder inV = DetachedVertex.build();
    inV.setId(kryo.readClassAndObject(input));
    inV.setLabel(input.readString());
    builder.setInV(inV.create());

    final DetachedVertex.Builder outV = DetachedVertex.build();
    outV.setId(kryo.readClassAndObject(input));
    outV.setLabel(input.readString());
    builder.setOutV(outV.create());

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

    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> 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 3
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 4
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertex.Builder v = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            v.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            v.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class));
                }
            }
        }
    }

    return v.create();
}
 
Example 5
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
public Vertex deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedVertex.Builder v = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            v.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            v.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    v.addProperty((DetachedVertexProperty) deserializationContext.readValue(jsonParser, VertexProperty.class));
                }
            }
        }
    }

    return v.create();
}
 
Example 6
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Edge deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedEdge.Builder e = DetachedEdge.build();
    final DetachedVertex.Builder inV = DetachedVertex.build();
    final DetachedVertex.Builder outV = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            e.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            e.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT)) {
            jsonParser.nextToken();
            outV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT_LABEL)) {
            jsonParser.nextToken();
            outV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN)) {
            jsonParser.nextToken();
            inV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN_LABEL)) {
            jsonParser.nextToken();
            inV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                e.addProperty(deserializationContext.readValue(jsonParser, Property.class));
            }
        }
    }

    e.setInV(inV.create());
    e.setOutV(outV.create());

    return e.create();
}
 
Example 7
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public Edge deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final DetachedEdge.Builder e = DetachedEdge.build();
    final DetachedVertex.Builder inV = DetachedVertex.build();
    final DetachedVertex.Builder outV = DetachedVertex.build();
    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals(GraphSONTokens.ID)) {
            jsonParser.nextToken();
            e.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.LABEL)) {
            jsonParser.nextToken();
            e.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT)) {
            jsonParser.nextToken();
            outV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.OUT_LABEL)) {
            jsonParser.nextToken();
            outV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN)) {
            jsonParser.nextToken();
            inV.setId(deserializationContext.readValue(jsonParser, Object.class));
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.IN_LABEL)) {
            jsonParser.nextToken();
            inV.setLabel(jsonParser.getText());
        } else if (jsonParser.getCurrentName().equals(GraphSONTokens.PROPERTIES)) {
            jsonParser.nextToken();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                jsonParser.nextToken();
                e.addProperty(deserializationContext.readValue(jsonParser, Property.class));
            }
        }
    }

    e.setInV(inV.create());
    e.setOutV(outV.create());

    return e.create();
}