本文整理汇总了Java中com.fasterxml.jackson.databind.JavaType.getRawClass方法的典型用法代码示例。如果您正苦于以下问题:Java JavaType.getRawClass方法的具体用法?Java JavaType.getRawClass怎么用?Java JavaType.getRawClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.JavaType
的用法示例。
在下文中一共展示了JavaType.getRawClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modifyEnumDeserializer
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@Override
public JsonDeserializer<?> modifyEnumDeserializer(DeserializationConfig config, JavaType type,
BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
if (Arrays.asList(Quality.class, Format.class).contains(type.getRawClass())) {
return new EnumDeserializer((Class<? extends Enum>) type.getRawClass());
}
return super.modifyEnumDeserializer(config, type, beanDesc, deserializer);
}
示例2: handleMissingTypeId
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@Override
public JavaType handleMissingTypeId(DeserializationContext ctxt, JavaType baseType, TypeIdResolver idResolver,
String failureMsg) throws IOException {
if (baseType.getRawClass() == Feature.class) {
return idResolver.typeFromId(ctxt, "Feature");
}
return super.handleMissingTypeId(ctxt, baseType, idResolver, failureMsg);
}
示例3: checkJavaType
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
protected void checkJavaType(Swagger swagger, JavaType javaType) {
Class<?> cls = javaType.getRawClass();
Field[] fields = cls.getFields();
Assert.assertEquals("gen.cse.ms.ut.User", cls.getName());
Assert.assertEquals("name", fields[0].getName());
Assert.assertEquals(String.class, fields[0].getType());
Assert.assertEquals("age", fields[1].getName());
Assert.assertEquals(Integer.class, fields[1].getType());
}
示例4: init
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@Override
public void init(JavaType baseType) {
this.baseType = baseType;
Class<?> baseClass = baseType.getRawClass();
TypesEnum typesEnum = baseClass.getAnnotation(TypesEnum.class);
while (baseClass != null && typesEnum == null) {
baseClass = baseClass.getSuperclass();
typesEnum = baseClass.getAnnotation(TypesEnum.class);
}
if (typesEnum == null) {
throw new NullPointerException("Missing annotation TypesEnum on " + baseType.getRawClass());
}
SubTypeMapping mapping = new SubTypeMapping(typesEnum);
TypeFactory defaultInstance = TypeFactory.defaultInstance();
StringBuilder sb = new StringBuilder();
for (Enum<?> e : mapping.getEnumConstants()) {
String name = e.name();
String className = mapping.getClassName(e);
try {
Class<?> c = Class.forName(className, false, this.getClass().getClassLoader());
JavaType type = defaultInstance.uncheckedSimpleType(c);
this.nameToType.put(name.toLowerCase(), type);
this.typeToName.put(c, name);
sb.append(name + " => " + c.getName() + "\n");
} catch (ClassNotFoundException e1) {
throw new RuntimeException(String.format(
"class not found %s for enum value %s for base type %s",
className, name, baseType
) , e1);
}
}
this.description = sb.toString();
}
示例5: initTypeInclusion
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
protected void initTypeInclusion(ObjectMapper mapObjectMapper) {
TypeResolverBuilder<?> mapTyper = new DefaultTypeResolverBuilder(DefaultTyping.NON_FINAL) {
public boolean useForType(JavaType t) {
switch (_appliesFor) {
case NON_CONCRETE_AND_ARRAYS:
while (t.isArrayType()) {
t = t.getContentType();
}
// fall through
case OBJECT_AND_NON_CONCRETE:
return (t.getRawClass() == Object.class) || !t.isConcrete();
case NON_FINAL:
while (t.isArrayType()) {
t = t.getContentType();
}
// to fix problem with wrong long to int conversion
if (t.getRawClass() == Long.class) {
return true;
}
if (t.getRawClass() == XMLGregorianCalendar.class) {
return false;
}
return !t.isFinal(); // includes Object.class
default:
// case JAVA_LANG_OBJECT:
return (t.getRawClass() == Object.class);
}
}
};
mapTyper.init(JsonTypeInfo.Id.CLASS, null);
mapTyper.inclusion(JsonTypeInfo.As.PROPERTY);
mapObjectMapper.setDefaultTyping(mapTyper);
// warm up codec
try {
byte[] s = mapObjectMapper.writeValueAsBytes(1);
mapObjectMapper.readValue(s, Object.class);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
示例6: EnumJsonDeserializer
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public EnumJsonDeserializer(JavaType javaType) {
this.enumClass = (Class<? extends Enum>) javaType.getRawClass();
}
示例7: useForType
import com.fasterxml.jackson.databind.JavaType; //导入方法依赖的package包/类
@Override
public boolean useForType(JavaType t) {
return !t.isPrimitive() && t.getRawClass() != ZonedDateTime.class;
}