All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.jackson.map.annotate.JsonDeserialize Maven / Gradle / Ivy

Go to download

Data Mapper package is a high-performance data binding package built on Jackson JSON processor

There is a newer version: 1.9.13
Show newest version
package org.codehaus.jackson.map.annotate;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.codehaus.jackson.annotate.JacksonAnnotation;
import org.codehaus.jackson.annotate.NoClass;
import org.codehaus.jackson.map.JsonDeserializer;

/**
 * Annotation use for configuring deserialization aspects, by attaching
 * to "setter" methods or fields, or to value classes.
 * When annotating value classes, configuration is used for instances
 * of the value class but can be overridden by more specific annotations
 * (ones that attach to methods or fields).
 *

* An example annotation would be: *

 *  @JsonDeserialize(using=MySerializer.class,
 *    as=MyHashMap.class,
 *    keyAs=MyHashKey.class,
 *    contentAs=MyHashValue.class
 *  )
 *
* * @since 1.1 */ @Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonDeserialize { /** * Deserializer class to use for deserializing associated value. * Depending on what is annotated, * value is either an instance of annotated class (used globablly * anywhere where class deserializer is needed); or only used for * deserializing property access via a setter method. */ public Class> using() default JsonDeserializer.None.class; /** * Concrete type to deserialize values as, instead of type otherwise * declared. Must be a subtype of declared type; otherwise an * exception may be thrown by deserializer. *

* Bogus type {@link NoClass} can be used to indicate that declared * type is used as is (i.e. this annotation property has no setting); * this since annotation properties are not allowed to have null value. *

* Note: if {@link #using} is also used it has precedence * (since it directly specified * deserializer, whereas this would only be used to locate the * deserializer) * and value of this annotation property is ignored. */ public Class as() default NoClass.class; /** * Concrete type to deserialize keys of {@link java.util.Map} as, * instead of type otherwise declared. * Must be a subtype of declared type; otherwise an exception may be * thrown by deserializer. *

* When annotating a class, will define default deserializer to * use when class instances are used as Map keys; when methods, * keys of the associated Map property. * Method annotation has precedence over class annotations, if both * exist. */ public Class keyAs() default NoClass.class; /** * Deserializer class to use for deserializing associated value * when it will used as contents of {@link java.util.Collection}, * {@link java.util.Map} and array types. *

* When annotating a class, will define default deserializer to * use when class instances are used as contents of collection/map/array * types; when methods, * keys of the associated collection/map/array property. * Method annotation has precedence over class annotations, if both * exist. */ public Class contentAs() default NoClass.class; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy