/** * Factory method that can be used if the full generic type has * been passed using {@link TypeReference}. This only needs to be * done if the root type to bind to is generic; but if so, * it must be done to get proper typing. * * @deprecated Use {@link #type(Type)} instead */ @Deprecated public static JavaType fromTypeReference(TypeReference<?> ref) { return type(ref.getType()); }
public static BackportedObjectReader create(ObjectMapper mapper, Class<?> type) { return new BackportedObjectReader(mapper, TypeFactory.type(type), null); }
@Deprecated public static JavaType mapType(Class<? extends Map> mapClass, Class<?> keyType, Class<?> valueType) { return instance.constructMapType(mapClass, type(keyType), instance.constructType(valueType)); }
String itemDefinition = null; if (typeHint != null) { Class<?> rawClass = TypeFactory.type(typeHint).getRawClass(); if (rawClass.isAnnotationPresent(JsonSerializableSchema.class)) { JsonSerializableSchema schemaInfo = rawClass.getAnnotation(JsonSerializableSchema.class);
/** * Return the Jackson {@link JavaType} for the specified type and context class. * <p>The default implementation returns {@link TypeFactory#type(java.lang.reflect.Type)} * or {@code TypeFactory.type(type, TypeFactory.type(contextClass))}, * but this can be overridden in subclasses, to allow for custom generic collection handling. * For instance: * <pre class="code"> * protected JavaType getJavaType(Type type) { * if (type instanceof Class && List.class.isAssignableFrom((Class)type)) { * return TypeFactory.collectionType(ArrayList.class, MyBean.class); * } else { * return super.getJavaType(type); * } * } * </pre> * @param type the type to return the java type for * @param contextClass a context class for the target type, for example a class * in which the target type appears in a method signature, can be {@code null} * @return the java type */ protected JavaType getJavaType(Type type, Class<?> contextClass) { return (contextClass != null) ? TypeFactory.type(type, TypeFactory.type(contextClass)) : TypeFactory.type(type); }
/** * Factory method that can be used if the full generic type has * been passed using {@link TypeReference}. This only needs to be * done if the root type to bind to is generic; but if so, * it must be done to get proper typing. * * @deprecated Use {@link #type(Type)} instead */ @Deprecated public static JavaType fromTypeReference(TypeReference<?> ref) { return type(ref.getType()); }
@Deprecated public static JavaType mapType(Class<? extends Map> mapClass, Class<?> keyType, Class<?> valueType) { return instance.constructMapType(mapClass, type(keyType), instance.constructType(valueType)); }
String itemDefinition = null; if (typeHint != null) { Class<?> rawClass = TypeFactory.type(typeHint).getRawClass(); if (rawClass.isAnnotationPresent(JsonSerializableSchema.class)) { JsonSerializableSchema schemaInfo = rawClass.getAnnotation(JsonSerializableSchema.class);
@SuppressWarnings("unchecked") private void add(Class<?> cls, JsonDeserializer<?> deser) { _allDeserializers.put(TypeFactory.type(cls), (JsonDeserializer<Object>) deser); }
/** * Convenience factory method for constructing {@link JavaType} that * represent Map of specified type and contains elements * of specified type * * @since 1.3 */ @SuppressWarnings("unchecked") public static JavaType mapType(Class<? extends Map> mapType, Class<?> keyType, Class<?> valueType) { return mapType(mapType, type(keyType), type(valueType)); }
/** * Factory method that can be used if the full generic type has * been passed using {@link TypeReference}. This only needs to be * done if the root type to bind to is generic; but if so, * it must be done to get proper typing. */ public static JavaType type(TypeReference<?> ref) { return type(ref.getType()); }
@SuppressWarnings("unchecked") public <T> T convertValue(Object fromValue, TypeReference toValueTypeRef) throws IllegalArgumentException { return (T) _convert(fromValue, TypeFactory.type(toValueTypeRef)); }
private void add(StdKeyDeserializer kdeser) { Class<?> keyClass = kdeser.getKeyClass(); _keyDeserializers.put(TypeFactory.type(keyClass), kdeser); }
private void add(StdDeserializer<?> stdDeser, Class<?> valueClass) { // must do some unfortunate casting here... @SuppressWarnings("unchecked") JsonDeserializer<Object> deser = (JsonDeserializer<Object>) stdDeser; _deserializers.put(TypeFactory.type(valueClass), deser); } }
@Deprecated public static JavaType mapType(Class<? extends Map> mapClass, Class<?> keyType, Class<?> valueType) { return instance.constructMapType(mapClass, type(keyType), instance.constructType(valueType)); }
@SuppressWarnings("unchecked") public <T> T readValue(File src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), TypeFactory.type(valueTypeRef)); }
@SuppressWarnings("unchecked") public <T> T readValue(File src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), TypeFactory.type(valueType)); }
@SuppressWarnings("unchecked") public <T> T readValue(Reader src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), TypeFactory.type(valueTypeRef)); }
@SuppressWarnings("unchecked") public <T> T readValue(String content, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(content), TypeFactory.type(valueType)); }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig cfg, Class<?> c, MixInResolver r) { AnnotationIntrospector ai = cfg.getAnnotationIntrospector(); AnnotatedClass ac = AnnotatedClass.construct(c, ai, r); return new BasicBeanDescription(TypeFactory.type(c), ac, ai); }