Search in sources :

Example 1 with StandardObjectReader

use of io.servicecomb.codec.protobuf.jackson.StandardObjectReader in project java-chassis by ServiceComb.

the class StandardParamCodec method init.

@Override
public void init(ProtobufSchema schema, Type... types) {
    writer = ProtobufManager.getMapper().writer(schema);
    reader = ProtobufManager.getMapper().reader(schema);
    // 需要考虑没参数的场景
    if (types.length == 1) {
        JavaType javaType = TypeFactory.defaultInstance().constructType(types[0]);
        writer = new StandardObjectWriter(writer.forType(javaType));
        reader = new StandardObjectReader(reader.forType(javaType));
    }
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) StandardObjectWriter(io.servicecomb.codec.protobuf.jackson.StandardObjectWriter) StandardObjectReader(io.servicecomb.codec.protobuf.jackson.StandardObjectReader)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 StandardObjectReader (io.servicecomb.codec.protobuf.jackson.StandardObjectReader)1 StandardObjectWriter (io.servicecomb.codec.protobuf.jackson.StandardObjectWriter)1