/** * Convenience method for constructing {@link JavaType} out of given * type (typically <code>java.lang.Class</code>), but without explicit * context. * * @since 1.8 */ public JavaType constructType(Type t) { return _typeFactory.constructType(t); }
/** * Method for constructing a {@link MapLikeType} instance *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. * * @since 1.8 */ public MapLikeType constructMapLikeType(Class<?> mapClass, Class<?> keyClass, Class<?> valueClass) { return MapType.construct(mapClass, constructType(keyClass), constructType(valueClass)); }
/** * Method for constructing a {@link MapType} instance *<p> * NOTE: type modifiers are NOT called on constructed type itself; but are called * for contained types. * * @since 1.8 */ public MapType constructMapType(Class<? extends Map> mapClass, Class<?> keyClass, Class<?> valueClass) { return MapType.construct(mapClass, constructType(keyClass), constructType(valueClass)); }
/** * @deprecated Since 1.8; instead use variant that takes JavaType: this ensures * that type information is properly resolved */ @Deprecated public JSONPObject(String function, Object value, Class<?> rawType) { _function = function; _value = value; _serializationType = (rawType == null) ? null : TypeFactory.defaultInstance().constructType(rawType); }
/** * Method for reading sequence of Objects from parser stream. * * @since 1.8 */ @Override public <T> MappingIterator<T> readValues(JsonParser jp, TypeReference<?> valueTypeRef) throws IOException, JsonProcessingException { return readValues(jp, _typeFactory.constructType(valueTypeRef)); }
/** * Factory method for constructing {@link ObjectReader} that will * read or update instances of specified type * * @since 1.6 */ public ObjectReader reader(Class<?> type) { return reader(_typeFactory.constructType(type)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T convertValue(Object fromValue, TypeReference toValueTypeRef) throws IllegalArgumentException { return (T) _convert(fromValue, _typeFactory.constructType(toValueTypeRef)); }
/** * Factory method for constructing {@link ObjectReader} that will * read or update instances of specified type * * @since 1.6 */ public ObjectReader reader(TypeReference<?> type) { return reader(_typeFactory.constructType(type)); }
@SuppressWarnings("unchecked") private void add(Class<?> cls, JsonDeserializer<?> deser) { /* Not super clean to use default TypeFactory in general, but * since primitive array types can't be modified for anything * useful, this should be ok: */ _allDeserializers.put(TypeFactory.defaultInstance().constructType(cls), (JsonDeserializer<Object>) 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", "rawtypes" }) public <T> T readValue(File src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), _typeFactory.constructType(valueTypeRef)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(URL src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), _typeFactory.constructType(valueTypeRef)); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(InputStream src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), _typeFactory.constructType(valueTypeRef)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime type. * * @since 1.9 */ public ObjectWriter writerWithType(TypeReference<?> rootType) { JavaType t = (rootType == null) ? null : _typeFactory.constructType(rootType); return new ObjectWriter(this, copySerializationConfig(), t, /*PrettyPrinter*/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. */ public ObjectReader withType(java.lang.reflect.Type valueType) { return withType(_config.getTypeFactory().constructType(valueType)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified root type, instead of actual * runtime type of value. Type must be a super-type of runtime * type. * * @since 1.9 */ public ObjectWriter writerWithType(Class<?> rootType) { JavaType t = (rootType == null) ? null : _typeFactory.constructType(rootType); return new ObjectWriter(this, copySerializationConfig(), t, /*PrettyPrinter*/null); }
/** * @since 1.7 */ public ObjectWriter withType(TypeReference<?> rootType) { return withType(_config.getTypeFactory().constructType(rootType.getType())); }
@SuppressWarnings("unchecked") public <T> T readValue(URL src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), _typeFactory.constructType(valueType)); }
@SuppressWarnings("unchecked") public <T> T readValue(String content, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createJsonParser(content), _typeFactory.constructType(valueType)); }
@SuppressWarnings("unchecked") public <T> T readValue(Reader src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createJsonParser(src), _typeFactory.constructType(valueType)); }