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

The following examples show how to use org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge#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: 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 3
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();
}