Java Code Examples for org.apache.tinkerpop.shaded.jackson.core.JsonToken#START_ARRAY

The following examples show how to use org.apache.tinkerpop.shaded.jackson.core.JsonToken#START_ARRAY . 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: GraphSONTypeSerializerV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public WritableTypeId writeTypePrefix(final JsonGenerator jsonGenerator, final WritableTypeId writableTypeId) throws IOException {
    if (writableTypeId.valueShape == JsonToken.START_OBJECT) {
        if (writableTypeId.forValue instanceof Map) {
            writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue)));
            jsonGenerator.writeStartArray();
        } else {
            jsonGenerator.writeStartObject();
        }
    } else if (writableTypeId.valueShape == JsonToken.START_ARRAY) {
        if (writableTypeId.forValue instanceof List || writableTypeId.forValue instanceof Set) {
            writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue)));
            jsonGenerator.writeStartArray();
        } else {
            jsonGenerator.writeStartArray();
        }
    } else if (canWriteTypeId()) {
        writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue)));
    } else {
        throw new IllegalStateException("Could not write prefix: shape[" + writableTypeId.valueShape + "] value[" + writableTypeId.forValue + "]");
    }

    return writableTypeId;
}
 
Example 2
Source File: GraphSONTypeSerializerV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public WritableTypeId writeTypeSuffix(final JsonGenerator jsonGenerator, final WritableTypeId writableTypeId) throws IOException {
    if (writableTypeId.valueShape == JsonToken.START_OBJECT) {
        if (writableTypeId.forValue instanceof Map) {
            jsonGenerator.writeEndArray();
            writeTypeSuffix(jsonGenerator);
        } else {
            jsonGenerator.writeEndObject();
        }
    } else if (writableTypeId.valueShape == JsonToken.START_ARRAY) {
        if (writableTypeId.forValue instanceof List || writableTypeId.forValue instanceof Set) {
            jsonGenerator.writeEndArray();
            writeTypeSuffix(jsonGenerator);
        } else {
            jsonGenerator.writeEndArray();
        }
    } else if (canWriteTypeId()) {
        writeTypeSuffix(jsonGenerator);
    } else {
        throw new IllegalStateException("Could not write suffix: shape[" + writableTypeId.valueShape + "] value[" + writableTypeId.forValue + "]");
    }

    return writableTypeId;
}
 
Example 3
Source File: GraphSONTypeSerializerV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public WritableTypeId writeTypePrefix(final JsonGenerator jsonGenerator, final WritableTypeId writableTypeId) throws IOException {
    if (writableTypeId.valueShape == JsonToken.START_OBJECT) {
        jsonGenerator.writeStartObject();
    } else if (writableTypeId.valueShape == JsonToken.START_ARRAY) {
        jsonGenerator.writeStartArray();
    } else if (canWriteTypeId()) {
        writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(writableTypeId.forValue, getClassFromObject(writableTypeId.forValue)));
    } else {
        throw new IllegalStateException("Could not write prefix: shape[" + writableTypeId.valueShape + "] value[" + writableTypeId.forValue + "]");
    }

    return writableTypeId;
}
 
Example 4
Source File: GraphSONTypeSerializerV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public WritableTypeId writeTypeSuffix(final JsonGenerator jsonGenerator, final WritableTypeId writableTypeId) throws IOException {
    if (writableTypeId.valueShape == JsonToken.START_OBJECT) {
        jsonGenerator.writeEndObject();
    } else if (writableTypeId.valueShape == JsonToken.START_ARRAY) {
        jsonGenerator.writeEndArray();
    } else if (canWriteTypeId()) {
        writeTypeSuffix(jsonGenerator);
    } else {
        throw new IllegalStateException("Could not write suffix: shape[" + writableTypeId.valueShape + "] value[" + writableTypeId.forValue + "]");
    }

    return writableTypeId;
}