/** * Method for specifying that annotations define by <code>mixinClass</code> * should be "mixed in" with annotations that <code>targetType</code> * has (as if they were directly included on it!). *<p> * Mix-in annotations are * registered when module is registered for <code>ObjectMapper</code>. */ public SimpleModule setMixInAnnotation(Class<?> targetType, Class<?> mixinClass) { _checkNotNull(targetType, "target type"); _checkNotNull(mixinClass, "mixin class"); if (_mixins == null) { _mixins = new HashMap<Class<?>, Class<?>>(); } _mixins.put(targetType, mixinClass); return this; }
/** * Method for adding set of subtypes (along with type name to use) to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. */ public SimpleModule registerSubtypes(NamedType ... subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (NamedType subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(subtype); } return this; }
public <T> SimpleModule addKeySerializer(Class<? extends T> type, JsonSerializer<T> ser) { _checkNotNull(type, "type to register key serializer for"); _checkNotNull(ser, "key serializer"); if (_keySerializers == null) { _keySerializers = new SimpleSerializers(); } _keySerializers.addSerializer(type, ser); return this; }
public SimpleModule addKeyDeserializer(Class<?> type, KeyDeserializer deser) { _checkNotNull(type, "type to register key deserializer for"); _checkNotNull(deser, "key deserializer"); if (_keyDeserializers == null) { _keyDeserializers = new SimpleKeyDeserializers(); } _keyDeserializers.addDeserializer(type, deser); return this; }
/** * Method for adding set of subtypes (along with type name to use) to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. * * @since 2.9 */ public SimpleModule registerSubtypes(Collection<Class<?>> subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (Class<?> subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(new NamedType(subtype)); } return this; }
/** * Method for registering {@link ValueInstantiator} to use when deserializing * instances of type <code>beanType</code>. *<p> * Instantiator is * registered when module is registered for <code>ObjectMapper</code>. */ public SimpleModule addValueInstantiator(Class<?> beanType, ValueInstantiator inst) { _checkNotNull(beanType, "class to register value instantiator for"); _checkNotNull(inst, "value instantiator"); if (_valueInstantiators == null) { _valueInstantiators = new SimpleValueInstantiators(); } _valueInstantiators = _valueInstantiators.addValueInstantiator(beanType, inst); return this; }
/** * Method for adding set of subtypes to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. */ public SimpleModule registerSubtypes(Class<?> ... subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (Class<?> subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(new NamedType(subtype)); } return this; }
/** * Lazily-constructed resolver used for storing mappings from * abstract classes to more specific implementing classes * (which may be abstract or concrete) */ public <T> SimpleModule addAbstractTypeMapping(Class<T> superType, Class<? extends T> subType) { _checkNotNull(superType, "abstract type to map"); _checkNotNull(subType, "concrete type to map to"); if (_abstractTypes == null) { _abstractTypes = new SimpleAbstractTypeResolver(); } // note: addMapping() will verify arguments _abstractTypes = _abstractTypes.addMapping(superType, subType); return this; }
/** * Method for adding serializer to handle values of specific type. *<p> * WARNING! Type matching only uses type-erased {@code Class} and should NOT * be used when registering serializers for generic types like * {@link java.util.Collection} and {@link java.util.Map}. */ public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser) { _checkNotNull(type, "type to register serializer for"); _checkNotNull(ser, "serializer"); if (_serializers == null) { _serializers = new SimpleSerializers(); } _serializers.addSerializer(type, ser); return this; }
/** * Method for adding deserializer to handle specified type. *<p> * WARNING! Type matching only uses type-erased {@code Class} and should NOT * be used when registering serializers for generic types like * {@link java.util.Collection} and {@link java.util.Map}. */ public <T> SimpleModule addDeserializer(Class<T> type, JsonDeserializer<? extends T> deser) { _checkNotNull(type, "type to register deserializer for"); _checkNotNull(deser, "deserializer"); if (_deserializers == null) { _deserializers = new SimpleDeserializers(); } _deserializers.addDeserializer(type, deser); return this; }
/** * Method for adding serializer to handle type that the serializer claims to handle * (see {@link JsonSerializer#handledType()}). *<p> * WARNING! Type matching only uses type-erased {@code Class} and should NOT * be used when registering serializers for generic types like * {@link java.util.Collection} and {@link java.util.Map}. */ public SimpleModule addSerializer(JsonSerializer<?> ser) { _checkNotNull(ser, "serializer"); if (_serializers == null) { _serializers = new SimpleSerializers(); } _serializers.addSerializer(ser); return this; }
/** * Method for adding set of subtypes (along with type name to use) to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. */ public SimpleModule registerSubtypes(NamedType ... subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (NamedType subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(subtype); } return this; }
public SimpleModule addKeyDeserializer(Class<?> type, KeyDeserializer deser) { _checkNotNull(type, "type to register key deserializer for"); _checkNotNull(deser, "key deserializer"); if (_keyDeserializers == null) { _keyDeserializers = new SimpleKeyDeserializers(); } _keyDeserializers.addDeserializer(type, deser); return this; }
public <T> SimpleModule addKeySerializer(Class<? extends T> type, JsonSerializer<T> ser) { _checkNotNull(type, "type to register key serializer for"); _checkNotNull(ser, "key serializer"); if (_keySerializers == null) { _keySerializers = new SimpleSerializers(); } _keySerializers.addSerializer(type, ser); return this; }
/** * Method for adding serializer to handle values of specific type. *<p> * WARNING! Type matching only uses type-erased {@code Class} and should NOT * be used when registering serializers for generic types like * {@link java.util.Collection} and {@link java.util.Map}. */ public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser) { _checkNotNull(type, "type to register serializer for"); _checkNotNull(ser, "serializer"); if (_serializers == null) { _serializers = new SimpleSerializers(); } _serializers.addSerializer(type, ser); return this; }
/** * Method for adding set of subtypes to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. */ public SimpleModule registerSubtypes(Class<?> ... subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (Class<?> subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(new NamedType(subtype)); } return this; }
/** * Method for adding deserializer to handle specified type. *<p> * WARNING! Type matching only uses type-erased {@code Class} and should NOT * be used when registering serializers for generic types like * {@link java.util.Collection} and {@link java.util.Map}. */ public <T> SimpleModule addDeserializer(Class<T> type, JsonDeserializer<? extends T> deser) { _checkNotNull(type, "type to register deserializer for"); _checkNotNull(deser, "deserializer"); if (_deserializers == null) { _deserializers = new SimpleDeserializers(); } _deserializers.addDeserializer(type, deser); return this; }
/** * Lazily-constructed resolver used for storing mappings from * abstract classes to more specific implementing classes * (which may be abstract or concrete) */ public <T> SimpleModule addAbstractTypeMapping(Class<T> superType, Class<? extends T> subType) { _checkNotNull(superType, "abstract type to map"); _checkNotNull(subType, "concrete type to map to"); if (_abstractTypes == null) { _abstractTypes = new SimpleAbstractTypeResolver(); } // note: addMapping() will verify arguments _abstractTypes = _abstractTypes.addMapping(superType, subType); return this; }
/** * Method for registering {@link ValueInstantiator} to use when deserializing * instances of type <code>beanType</code>. *<p> * Instantiator is * registered when module is registered for <code>ObjectMapper</code>. */ public SimpleModule addValueInstantiator(Class<?> beanType, ValueInstantiator inst) { _checkNotNull(beanType, "class to register value instantiator for"); _checkNotNull(inst, "value instantiator"); if (_valueInstantiators == null) { _valueInstantiators = new SimpleValueInstantiators(); } _valueInstantiators = _valueInstantiators.addValueInstantiator(beanType, inst); return this; }
/** * Method for adding set of subtypes (along with type name to use) to be registered with * {@link ObjectMapper} * this is an alternative to using annotations in super type to indicate subtypes. * * @since 2.9 */ public SimpleModule registerSubtypes(Collection<Class<?>> subtypes) { if (_subtypes == null) { _subtypes = new LinkedHashSet<>(); } for (Class<?> subtype : subtypes) { _checkNotNull(subtype, "subtype to register"); _subtypes.add(new NamedType(subtype)); } return this; }