Java Code Examples for com.fasterxml.jackson.databind.JavaType#isJavaLangObject()

The following examples show how to use com.fasterxml.jackson.databind.JavaType#isJavaLangObject() . 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: Int32ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (int.class.equals(javaType.getRawClass())) {
    return new IntFieldIntPrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (short.class.equals(javaType.getRawClass())) {
    return new ShortFieldIntPrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (byte.class.equals(javaType.getRawClass())) {
    return new ByteFieldIntPrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || Byte.class.equals(javaType.getRawClass()) || Short.class
      .equals(javaType.getRawClass()) || javaType
      .isJavaLangObject()) {
    return new Int32Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 2
Source File: DeserializerSchemaManager.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Override
protected <T> SchemaEx<T> newMessageSchema(Message message, JavaType javaType) {
  if (ProtoUtils.isWrapProperty(message) && javaType.getRawClass() != PropertyWrapper.class) {
    Field protoField = message.getField(1);
    if (javaType.isJavaLangObject()) {
      javaType =
          protoField.isRepeated() && !protoField.isMap() ? ProtoConst.LIST_TYPE
              : ProtoConst.MAP_TYPE;
    }

    if (javaType.isPrimitive()) {
      javaType = TypeFactory.defaultInstance()
          .constructParametricType(PropertyWrapper.class, TypesUtil.primitiveJavaTypeToWrapper(javaType));
    } else {
      javaType = TypeFactory.defaultInstance().constructParametricType(PropertyWrapper.class, javaType);
    }
  }

  if (javaType.isJavaLangObject()) {
    javaType = ProtoConst.MAP_TYPE;
  }

  return new MessageReadSchema<>(protoMapper, message, javaType);
}
 
Example 3
Source File: EnumsReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (javaType.isEnumType()) {
    return new EnumSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new IntEnumSchema<>(protoField, propertyDescriptor);
  }

  if (int.class.equals(javaType.getRawClass())) {
    return new IntPrimitiveEnumSchema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 4
Source File: UInt32ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (int.class.equals(javaType.getRawClass())) {
    return new UInt32PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new UInt32Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 5
Source File: UInt64ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (long.class.equals(javaType.getRawClass())) {
    return new UInt64PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new UInt64Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 6
Source File: Fixed32ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (int.class.equals(javaType.getRawClass())) {
    return new Fixed32PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new Fixed32Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 7
Source File: BoolReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (boolean.class.equals(javaType.getRawClass())) {
    return new BooleanPrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Boolean.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new BooleanSchema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 8
Source File: SFixed64ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (long.class.equals(javaType.getRawClass())) {
    return new SFixed64PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new SFixed64Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 9
Source File: SFixed32ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (int.class.equals(javaType.getRawClass())) {
    return new SFixed32PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new SFixed32Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 10
Source File: Fixed64ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (long.class.equals(javaType.getRawClass())) {
    return new Fixed64PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new Fixed64Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 11
Source File: SInt64ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (long.class.equals(javaType.getRawClass())) {
    return new SInt64PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new SInt64Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 12
Source File: FloatReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (float.class.equals(javaType.getRawClass())) {
    return new FloatPrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Float.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new FloatSchema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 13
Source File: RepeatedReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T, ELE_TYPE> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor,
    AbstractReaders<ELE_TYPE> readers) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (readers.arrayClass.isAssignableFrom(javaType.getRawClass())) {
    return new ArrayRepeatedSchema<>(protoField, propertyDescriptor, readers);
  }

  if (Collection.class.isAssignableFrom(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new CollectionRepeatedSchema<>(protoField, propertyDescriptor, readers);
  }

  ProtoUtils.throwNotSupportMerge(protoField, javaType);
  return null;
}
 
Example 14
Source File: SInt32ReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (int.class.equals(javaType.getRawClass())) {
    return new SInt32PrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Integer.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new SInt32Schema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 15
Source File: BytesReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (byte[].class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new BytesSchema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 16
Source File: DoubleReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (double.class.equals(javaType.getRawClass())) {
    return new DoublePrimitiveSchema<>(protoField, propertyDescriptor);
  }

  if (Double.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
    return new DoubleSchema<>(protoField, propertyDescriptor);
  }

  ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
  return null;
}
 
Example 17
Source File: SchemaManager.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
protected <T> FieldSchema<T> createMapFieldSchema(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (javaType.isJavaLangObject()) {
    javaType = ProtoConst.MAP_TYPE;
  }

  JavaType entryType = TypeFactory.defaultInstance().constructParametricType(MapEntry.class,
      javaType.getKeyType(),
      javaType.getContentType());
  SchemaEx<Entry<Object, Object>> entrySchema = getOrCreateMessageSchema((Message) protoField.getType(),
      entryType);
  return new MapSchema<>(protoField, propertyDescriptor, entrySchema);
}
 
Example 18
Source File: MessageReadSchema.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public MessageReadSchema(ProtoMapper protoMapper, Message message, JavaType javaType) {
  this.protoMapper = protoMapper;
  this.message = message;
  this.javaType = javaType;
  if (javaType.isJavaLangObject() || Map.class.isAssignableFrom(javaType.getRawClass())) {
    javaType = ProtoConst.MAP_TYPE;
  }
  this.instantiator = RuntimeEnv.newInstantiator((Class<T>) javaType.getRawClass());
}
 
Example 19
Source File: EnumPackedReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (javaType.isJavaLangObject()) {
    return new EnumIntPackedSchema<>(protoField, propertyDescriptor);
  }

  return RepeatedReadSchemas
      .create(protoField, propertyDescriptor, new EnumPackedReaders(protoField, propertyDescriptor.getJavaType()));
}
 
Example 20
Source File: EnumNotPackedReadSchemas.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
  JavaType javaType = propertyDescriptor.getJavaType();
  if (javaType.isJavaLangObject()) {
    return new EnumIntNotPackedSchema<>(protoField, propertyDescriptor);
  }

  return RepeatedReadSchemas
      .create(protoField, propertyDescriptor, new EnumNotPackedReaders(protoField, propertyDescriptor.getJavaType()));
}