/** * Since 2.6 */ public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { acceptJsonFormatVisitor(_config.constructType(rawType), visitor); }
/** * @since 2.7 */ public JsonSerializer<Object> findKeySerializer(Class<?> rawKeyType, BeanProperty property) throws JsonMappingException { return findKeySerializer(_config.constructType(rawKeyType), property); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. * * @since 2.5 */ public ObjectWriter forType(Class<?> rootType) { if (rootType == Object.class) { return forType((JavaType) null); } return forType(_config.constructType(rootType)); }
/** * Method that will try to construct a value serializer; and if * one is successfully created, cache it for reuse. */ protected JsonSerializer<Object> _createAndCacheUntypedSerializer(Class<?> rawType) throws JsonMappingException { JavaType fullType = _config.constructType(rawType); JsonSerializer<Object> ser; try { ser = _createUntypedSerializer(fullType); } catch (IllegalArgumentException iae) { // We better only expose checked exceptions, since those // are what caller is expected to handle ser = null; // doesn't matter but compiler whines otherwise reportMappingProblem(iae, ClassUtil.exceptionMessage(iae)); } if (ser != null) { // 21-Dec-2015, tatu: Best to cache for both raw and full-type key _serializerCache.addAndResolveNonTypedSerializer(rawType, fullType, ser, this); } return ser; }
/** * Method variant used when we do NOT want contextualization to happen; it will need * to be handled at a later point, but caller wants to be able to do that * as needed; sometimes to avoid infinite loops * * @since 2.5 */ public JsonSerializer<Object> findValueSerializer(Class<?> valueType) throws JsonMappingException { // (see comments from above method) JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } } } } } return ser; }
/** * @since 2.3 */ @SuppressWarnings("unchecked") public JsonSerializer<Object> findPrimaryPropertySerializer(Class<?> valueType, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } return ser; } } } } return (JsonSerializer<Object>) handlePrimaryContextualization(ser, property); }
if (ser == null) { ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) {
_config.constructType(valueType)); if (typeSer != null) { typeSer = typeSer.forProperty(property);
/** * Creates a new {@link JacksonMetadata} instance for the given {@link ObjectMapper} and type. * * @param mapper must not be {@literal null}. * @param type must not be {@literal null}. */ public JacksonMetadata(ObjectMapper mapper, Class<?> type) { Assert.notNull(mapper, "ObjectMapper must not be null!"); Assert.notNull(type, "Type must not be null!"); this.mapper = mapper; SerializationConfig serializationConfig = mapper.getSerializationConfig(); JavaType javaType = serializationConfig.constructType(type); BeanDescription description = serializationConfig.introspect(javaType); this.definitions = description.findProperties(); this.isValue = description.findJsonValueMethod() != null; DeserializationConfig deserializationConfig = mapper.getDeserializationConfig(); JavaType deserializationType = deserializationConfig.constructType(type); this.deserializationDefinitions = deserializationConfig.introspect(deserializationType).findProperties(); }
private static AnnotatedClass buildNewAnnotatedClass(Method method, Class<?> declaringClass, SerializationConfig serializationConfig) throws InvocationTargetException, IllegalAccessException { JavaType declaringType = serializationConfig.constructType(declaringClass); return AnnotatedClass.class.cast(method.invoke(null, declaringType, serializationConfig, serializationConfig)); }
/** * Since 2.6 */ public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { acceptJsonFormatVisitor(_config.constructType(rawType), visitor); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. */ public ObjectWriter withType(Class<?> rootType) { return withType(_config.constructType(rootType)); }
/** * @since 2.7 */ public JsonSerializer<Object> findKeySerializer(Class<?> rawKeyType, BeanProperty property) throws JsonMappingException { return findKeySerializer(_config.constructType(rawKeyType), property); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. */ public ObjectWriter withType(Class<?> rootType) { return withType(_config.constructType(rootType)); }
/** * @since 2.7 */ public JsonSerializer<Object> findKeySerializer(Class<?> rawKeyType, BeanProperty property) throws JsonMappingException { return findKeySerializer(_config.constructType(rawKeyType), property); }
/** * Since 2.6 */ public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { acceptJsonFormatVisitor(_config.constructType(rawType), visitor); }
/** * @deprecated since 2.6; remove from 2.7 or later */ @Deprecated public void serializePolymorphic(JsonGenerator gen, Object value, TypeSerializer typeSer) throws IOException { JavaType t = (value == null) ? null : _config.constructType(value.getClass()); serializePolymorphic(gen, value, t, null, typeSer); }
@Override public void serialize(Resources value, JsonGenerator jgen, SerializerProvider provider) throws IOException { final SerializationConfig config = provider.getConfig(); JavaType javaType = config.constructType(value.getClass()); JsonSerializer<Object> serializer = BeanSerializerFactory.instance.createSerializer(provider, javaType); jgen.writeStartObject(); serializer.serialize(value, jgen, provider); jgen.writeEndObject(); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. * * @since 2.5 */ public ObjectWriter forType(Class<?> rootType) { if (rootType == Object.class) { return forType((JavaType) null); } return forType(_config.constructType(rootType)); }
/** * Method that will construct a new instance that uses specific type * as the root type for serialization, instead of runtime dynamic * type of the root object itself. * * @since 2.5 */ public ObjectWriter forType(Class<?> rootType) { if (rootType == Object.class) { return forType((JavaType) null); } return forType(_config.constructType(rootType)); }