/** * 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 type(TypeReference<?> ref) { return instance.constructType(ref.getType()); }
public JavaType constructType(TypeReference<?> typeRef) { return _constructType(typeRef.getType(), null); }
/** * Helper method that will construct {@link JavaType} for given * type reference * This is a simple short-cut for: *<pre> * getTypeFactory().constructType(valueTypeRef); *</pre> * * @since 1.9 */ public final JavaType constructType(TypeReference<?> valueTypeRef) { return getTypeFactory().constructType(valueTypeRef.getType(), (TypeBindings) null); }
/** * Method for constructing a new reader instance that is configured * to data bind into specified type. *<p> * Note that the method does NOT change state of this reader, but * rather construct and returns a newly configured instance. * * @since 1.8 */ public ObjectReader withType(TypeReference<?> valueTypeRef) { return withType(_config.getTypeFactory().constructType(valueTypeRef.getType())); }
/** * @since 1.7 */ public ObjectWriter withType(TypeReference<?> rootType) { return withType(_config.getTypeFactory().constructType(rootType.getType())); }
/** * 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 type(TypeReference<?> ref) { return instance.constructType(ref.getType()); }
public JavaType constructType(TypeReference<?> typeRef) { return _constructType(typeRef.getType(), null); }
/** * Helper method that will construct {@link JavaType} for given * type reference * This is a simple short-cut for: *<pre> * getTypeFactory().constructType(valueTypeRef); *</pre> * * @since 1.9 */ public final JavaType constructType(TypeReference<?> valueTypeRef) { return getTypeFactory().constructType(valueTypeRef.getType(), (TypeBindings) null); }
/** * @since 1.7 */ public ObjectWriter withType(TypeReference<?> rootType) { return withType(_config.getTypeFactory().constructType(rootType.getType())); }
/** * Method for constructing a new reader instance that is configured * to data bind into specified type. *<p> * Note that the method does NOT change state of this reader, but * rather construct and returns a newly configured instance. * * @since 1.8 */ public ObjectReader withType(TypeReference<?> valueTypeRef) { return withType(_config.getTypeFactory().constructType(valueTypeRef.getType())); }
public <DTO> DTO payloadJsonAs(TypeReference<DTO> typeReference) { return new Gson().fromJson(payload, typeReference.getType()); }
/** * 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 */ public static JavaType fromTypeReference(TypeReference<?> ref) { return type(ref.getType()); }
@Deprecated public static JavaType type(TypeReference<?> ref) { return instance.constructType(ref.getType()); }
/** * 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()); }
/** * * @param str * @param typeReference * @param <T> * @return */ public static <T> T string2Obj(String str, TypeReference<T> typeReference){ if(StringUtils.isEmpty(str) || typeReference == null){ return null; } try { return (T)(typeReference.getType().equals(String.class)? str : objectMapper.readValue(str,typeReference)); } catch (Exception e) { log.warn("Parse String to Object error",e); return null; } }
/** * 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 type(TypeReference<?> ref) { return instance.constructType(ref.getType()); }
/** * 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()); }