use of org.apache.servicecomb.foundation.protobuf.internal.schema.any.AnySchema in project incubator-servicecomb-java-chassis by apache.
the class SerializerSchemaManager method createRepeatedSchema.
@Override
protected <T> FieldSchema<T> createRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor) {
boolean packed = ProtoUtils.isPacked(protoField);
if (protoField.getType().isEnum()) {
return packed ? EnumPackedWriteSchemas.create(protoField, propertyDescriptor) : EnumNotPackedWriteSchemas.create(protoField, propertyDescriptor);
}
if (protoField.getType().isScalar()) {
switch((ScalarFieldType) protoField.getType()) {
case INT32:
return packed ? Int32PackedWriteSchemas.create(protoField, propertyDescriptor) : Int32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case UINT32:
return packed ? UInt32PackedWriteSchemas.create(protoField, propertyDescriptor) : UInt32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SINT32:
return packed ? SInt32PackedWriteSchemas.create(protoField, propertyDescriptor) : SInt32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FIXED32:
return packed ? Fixed32PackedWriteSchemas.create(protoField, propertyDescriptor) : Fixed32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SFIXED32:
return packed ? SFixed32PackedWriteSchemas.create(protoField, propertyDescriptor) : SFixed32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case INT64:
return packed ? Int64PackedWriteSchemas.create(protoField, propertyDescriptor) : Int64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case UINT64:
return packed ? UInt64PackedWriteSchemas.create(protoField, propertyDescriptor) : UInt64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SINT64:
return packed ? SInt64PackedWriteSchemas.create(protoField, propertyDescriptor) : SInt64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FIXED64:
return packed ? Fixed64PackedWriteSchemas.create(protoField, propertyDescriptor) : Fixed64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SFIXED64:
return packed ? SFixed64PackedWriteSchemas.create(protoField, propertyDescriptor) : SFixed64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FLOAT:
return packed ? FloatPackedWriteSchemas.create(protoField, propertyDescriptor) : FloatNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case DOUBLE:
return packed ? DoublePackedWriteSchemas.create(protoField, propertyDescriptor) : DoubleNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case BOOL:
return packed ? BoolPackedWriteSchemas.create(protoField, propertyDescriptor) : BoolNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case STRING:
return StringsRepeatedWriteSchemas.create(protoField, propertyDescriptor);
case BYTES:
return BytesRepeatedWriteSchemas.create(protoField, propertyDescriptor);
}
}
if (ProtoUtils.isAnyField(protoField)) {
FieldSchema<T> anySchema = new AnySchema<>(protoMapper, protoField, propertyDescriptor);
return AnyRepeatedWriteSchemas.create(protoField, propertyDescriptor, anySchema);
}
if (protoField.getType().isMessage()) {
JavaType contentType = propertyDescriptor.getJavaType().getContentType();
if (contentType == null) {
contentType = ProtoConst.OBJECT_TYPE;
}
SchemaEx<Object> contentSchema = getOrCreateMessageSchema((Message) protoField.getType(), contentType);
if (isWrapProperty((Message) protoField.getType())) {
return PropertyWrapperRepeatedWriteSchemas.create(protoField, propertyDescriptor, contentSchema);
}
return MessagesRepeatedWriteSchemas.create(protoField, propertyDescriptor, contentSchema);
}
ProtoUtils.throwNotSupportWrite(protoField, propertyDescriptor.getJavaType().getRawClass());
return null;
}
use of org.apache.servicecomb.foundation.protobuf.internal.schema.any.AnySchema in project java-chassis by ServiceComb.
the class SerializerSchemaManager method createRepeatedSchema.
@Override
protected <T> FieldSchema<T> createRepeatedSchema(Field protoField, PropertyDescriptor propertyDescriptor) {
boolean packed = ProtoUtils.isPacked(protoField);
if (protoField.getType().isEnum()) {
return packed ? EnumPackedWriteSchemas.create(protoField, propertyDescriptor) : EnumNotPackedWriteSchemas.create(protoField, propertyDescriptor);
}
if (protoField.getType().isScalar()) {
switch((ScalarFieldType) protoField.getType()) {
case INT32:
return packed ? Int32PackedWriteSchemas.create(protoField, propertyDescriptor) : Int32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case UINT32:
return packed ? UInt32PackedWriteSchemas.create(protoField, propertyDescriptor) : UInt32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SINT32:
return packed ? SInt32PackedWriteSchemas.create(protoField, propertyDescriptor) : SInt32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FIXED32:
return packed ? Fixed32PackedWriteSchemas.create(protoField, propertyDescriptor) : Fixed32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SFIXED32:
return packed ? SFixed32PackedWriteSchemas.create(protoField, propertyDescriptor) : SFixed32NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case INT64:
return packed ? Int64PackedWriteSchemas.create(protoField, propertyDescriptor) : Int64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case UINT64:
return packed ? UInt64PackedWriteSchemas.create(protoField, propertyDescriptor) : UInt64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SINT64:
return packed ? SInt64PackedWriteSchemas.create(protoField, propertyDescriptor) : SInt64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FIXED64:
return packed ? Fixed64PackedWriteSchemas.create(protoField, propertyDescriptor) : Fixed64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case SFIXED64:
return packed ? SFixed64PackedWriteSchemas.create(protoField, propertyDescriptor) : SFixed64NotPackedWriteSchemas.create(protoField, propertyDescriptor);
case FLOAT:
return packed ? FloatPackedWriteSchemas.create(protoField, propertyDescriptor) : FloatNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case DOUBLE:
return packed ? DoublePackedWriteSchemas.create(protoField, propertyDescriptor) : DoubleNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case BOOL:
return packed ? BoolPackedWriteSchemas.create(protoField, propertyDescriptor) : BoolNotPackedWriteSchemas.create(protoField, propertyDescriptor);
case STRING:
return StringsRepeatedWriteSchemas.create(protoField, propertyDescriptor);
case BYTES:
return BytesRepeatedWriteSchemas.create(protoField, propertyDescriptor);
}
}
if (ProtoUtils.isAnyField(protoField)) {
FieldSchema<T> anySchema = new AnySchema<>(protoMapper, protoField, propertyDescriptor);
return AnyRepeatedWriteSchemas.create(protoField, propertyDescriptor, anySchema);
}
if (protoField.getType().isMessage()) {
JavaType contentType = propertyDescriptor.getJavaType().getContentType();
if (contentType == null) {
contentType = ProtoConst.OBJECT_TYPE;
}
SchemaEx<Object> contentSchema = getOrCreateMessageSchema((Message) protoField.getType(), contentType);
if (isWrapProperty((Message) protoField.getType())) {
return PropertyWrapperRepeatedWriteSchemas.create(protoField, propertyDescriptor, contentSchema);
}
return MessagesRepeatedWriteSchemas.create(protoField, propertyDescriptor, contentSchema);
}
ProtoUtils.throwNotSupportWrite(protoField, propertyDescriptor.getJavaType().getRawClass());
return null;
}
Aggregations