pax_global_header00006660000000000000000000000064121505603170014512gustar00rootroot0000000000000052 comment=7f7ded8e2c2859021868430ec491ecde53949358 jackson-annotations-jackson-annotations-2.2.2/000077500000000000000000000000001215056031700214615ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/.gitignore000066400000000000000000000002351215056031700234510ustar00rootroot00000000000000# use glob syntax. syntax: glob *.class *~ *.bak *.off *.old .DS_Store # building target # Eclipse .classpath .project .settings # IDEA *.iml *.ipr *.iws jackson-annotations-jackson-annotations-2.2.2/README.md000066400000000000000000000171271215056031700227500ustar00rootroot00000000000000# Overview This project contains general purpose annotations for Jackson Data Processor, used on value and handler types. The only annotations not included are ones that require dependency to the [Databind package](/FasterXML/jackson-databind). Project contains versions 2.0 and above: source code for earlier (1.x) versions is available from [Codehaus](http://jackson.codehaus.org) SVN repository. Note that with version 1.x these annotations were part of the 'core jar'. [Full Listing of Jackson Annotations](../../wiki/Jackson-Annotations) details all available annotations; [Javadocs](http://fasterxml.github.com/jackson-annotations/javadoc/2.2.0/) gives more details. ----- ## Usage, general ### Improvements over typical Java annotations In addition to regular usage (see below), there are couple of noteworthy improvements Jackson does: * [Mix-in annotations](../../wiki/Mixin-Annotations) allow associating annotations on third-party classes ''without modifying classes''. * Jackson annotations support full inheritance: meaning that you can ''override annotation definitions'', and not just class annotations but also method/field annotations! ### Maven, Java package All annotations are in Java package `com.fasterxml.core.annotation`. To use annotations, you need to use Maven dependency: ```xml com.fasterxml.jackson.core jackson-annotations 2.2.0 ``` or download jars from Maven repository or [Download page](http://wiki.fasterxml.com/JacksonDownload) ## Usage, simple Let's start with simple use cases: renaming or ignoring properties, and modifying types that are used. Note: while examples only show field properties, same annotations would work with method (getter/setter) properties. ### Annotations for renaming properties One of most common tasks is to change JSON name used for a property: for example: ```java public class Name { @JsonProperty("firstName") public String _first_name; } ``` would result in JSON like: ```json { "firstName" : "Bob" } ``` instead of ```json { "_first_name" : "Bob" } ``` ### Annotations for Ignoring properties Sometimes POJOs contain properties that you do not want to write out, so you can do: ```java public class Value { public int value; @JsonIgnore public int internalValue; } ``` and get JSON like: ```json { "value" : 42 } ``` or, you may get properties in JSON that you just want to skip: if so, you can use: ```java @JsonIgnoreProperties({ "extra", "uselessValue" }) public class Value { public int value; } ``` which would be able to handle JSON like: ```json { "value" : 42, "extra" : "fluffy", "uselessValue" : -13 } ``` Finally, you may even want to just ignore any "extra" properties from JSON (ones for which there is no counterpart in POJO). This can be done by adding: ```java @JsonIgnoreProperties(ignoreUnknown=true) public class PojoWithAny { public int value; } ``` ### Annotations for choosing more/less specific types Sometimes the type Jackson uses when reading or writing a property is not quite what you want: * When reading (deserializing), declared type may be a general type, but you know which exact implementation type to use * When writing (serializing), Jackson will by default use the specific runtime type; but you may not want to include all information from that type but rather just contents of its supertype. These cases can be handled by following annotations: ```java public class ValueContainer { // although nominal type is 'Value', we want to read JSON as 'ValueImpl' @JsonDeserialize(as=ValueImpl.class) public Value value; // although runtime type may be 'AdvancedType', we really want to serialize // as 'BasicType'; two ways to do this: @JsonSerialize(as=BasicType.class) // or could also use: @JsonSerialize(typing=Typing.STATIC) public BasicType another; } ``` ----- ## Usage, intermediate ### Using constructors or factory methods By default, Jackson tries to use the "default" constructor (one that takes no arguments), when creating value instances. But you can also choose to use another constructor, or a static factory method to create instance. To do this, you will need to use annotation `@JsonCreator`, and possibly `@JsonProperty` annotations to bind names to arguments: ```java public class CtorPOJO { private final int _x, _y; @JsonCreator public CtorPOJO(@JsonProperty("x") int x, @JsonProperty("y") int y) { _x = x; _y = y; } } ``` `@JsonCreator` can be used similarly for static factory methods. But there is also an alternative usage, which is so-called "delegating" creator: ```java public class DelegatingPOJO { private final int _x, _y; @JsonCreator public DelegatingPOJO(Map delegate) { _x = (Integer) delegate.get("x"); _y = (Integer) delegate.get("y"); } } ``` the difference being that the creator method can only take one argument, and that argument must NOT have `@JsonProperty` annotation. ### Handling polymorphic types If you need to read and write values of Objects where there are multiple possible subtypes (i.e. ones that exhibit polymorphism), you may need to enable inclusion of type information. This is needed so that Jackson can read back correct Object type when deserializing (reading JSON into Objects). This can be done by adding `@JsonTypeInfo` annotation on ''base class'': ```java // Include Java class name ("com.myempl.ImplClass") as JSON property "class" @JsonTypeInfo(use=Id.CLASS, include=As.PROPERTY, property="class") public abstract class BaseClass { } public class Impl1 extends BaseClass { public int x; } public class Impl2 extends BaseClass { public String name; } public class PojoWithTypedObjects { public List items; } ``` and this could result in serialized JSON like: ```json { "items" : [ { "class":"Impl2", "name":"Bob" }, { "class":"Impl1", "x":13 } ]} ``` Note that this annotation has lots of configuration possibilities: for more information check out [Intro to polymorphic type handling](http://www.cowtowncoder.com/blog/archives/2010/03/entry_372.html) ### Changing property auto-detection The default Jackson property detection rules will find: * All ''public'' fields * All ''public'' getters ('getXxx()' methods) * All setters ('setXxx(value)' methods), ''regardless of visibility'') But if this does not work, you can change visibility levels by using annotation `@JsonAutoDetect`. If you wanted, for example, to auto-detect ALL fields (similar to how packages like GSON work), you could do: ```java @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY) public class POJOWithFields { private int value; } ``` or, to disable auto-detection of fields altogether: ```java @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.NONE) public class POJOWithNoFields { // will NOT be included, unless there is access 'getValue()' public int value; } ``` ----- # Further reading Project-specific documentation: * [Full Listing of Jackson Annotations](../../wiki/JacksonAnnotations) details all available annotations. * [Documentation](../../wiki/Documentation) Usage: * You can make Jackson 2 use Jackson 1 annotations with [jackson-legacy-introspector](https://github.com/Laures/jackson-legacy-introspector) Related: * [Databinding](https://github.com/FasterXML/jackson-databind) module has more documentation, since it is the main user of annotations. In addition, here are other useful links: * [Jackson Project Home](http://wiki.fasterxml.com/JacksonHome) * [Annotation documentation at FasterXML Wiki](http://wiki.fasterxml.com/JacksonAnnotations) covers 1.x annotations as well as 2.0 jackson-annotations-jackson-annotations-2.2.2/pom.xml000066400000000000000000000023511215056031700227770ustar00rootroot00000000000000 4.0.0 com.fasterxml oss-parent 10 com.fasterxml.jackson.core jackson-annotations Jackson-annotations 2.2.2 Core annotations used for value types, used by Jackson data binding package. http://wiki.fasterxml.com/JacksonHome scm:git:git@github.com:FasterXML/jackson-annotations.git scm:git:git@github.com:FasterXML/jackson-annotations.git http://github.com/FasterXML/jackson-annotations jackson-annotations-2.2.2 com.fasterxml.jackson.annotation.*;version=${project.version} jackson-annotations-jackson-annotations-2.2.2/release-notes/000077500000000000000000000000001215056031700242275ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/release-notes/VERSION000066400000000000000000000044441215056031700253050ustar00rootroot00000000000000Project: jackson-annotations Version: 2.2.2 (26-May-2013) No changes from previous version. ------------------------------------------------------------------------ === History: === ------------------------------------------------------------------------ 2.2.1 (03-May-2013) - Moved LICENSE file under 'META-INF/' in jar 2.2.0 (22-Apr-2013) New minor version, but no changes since 2.1.0. 2.1.1 (11-Nov-2012) Fixes: * Make ObjectIdGenerator java.io.Serializable (needed when serializing ObjectMappers/-Writers/-Readers) 2.1.0 (08-Oct-2012) New features: * [Issue#4]: Add '@JsonIdentityReference', to support use case where values of a specific reference property are always serialized as ids, never as full POJO Improvements: * Added '@JsonIdentityInfo.firstAsID' property, to allow forcing all references to an Object to be serialized as id, including first one. * Fix OSGi artifact name to be fully-qualified 2.0.2 (14-May-2012) Fixes: * OSGi bundle name was accidentally changed in 2.0.1; reverted back to one used in 2.0.0, earlier (reported Pascal G) 2.0.1 (22-Apr-2012) Fixes: * [JACKSON-827] Fix incompatibilities with JDK 1.5 (2.0.0 accidentally required 1.6) (reported Pascal G) 2.0.0 (25-Mar-2012) Improvements: * [JACKSON-437]: Allow injecting of type id as POJO property, by setting new '@JsonTypeInfo.visible' property to true. * [JACKSON-669]: Allow prefix/suffix for @JsonUnwrapped properties (requested by Aner P) * [JACKSON-787]: @JsonIgnoredProperties can be used on properties too New features: * [JACKSON-107]: Add support for Object Identity (to handled cycles, shared refs), with @JsonIdentityInfo * [JACKSON-714] Add general-purpose '@JsonFormat' annotation * [JACKSON-752]: Add @JsonInclude (replacement of @JsonSerialize.include) * [JACKSON-754]: Add @JacksonAnnotationsInside for creating "annotation bundles" (also: AnnotationIntrospector.isAnnotationBundle()) Other: * Lots of miscellaneous refactoring; moving most annotations from databind into this package; only leaving ones that depend on databind package types ------------------------------------------------------------------------ === History: === ------------------------------------------------------------------------ [entries for versions 1.x and earlier not retained; refer to earlier releases) jackson-annotations-jackson-annotations-2.2.2/src/000077500000000000000000000000001215056031700222505ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/000077500000000000000000000000001215056031700231745ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/000077500000000000000000000000001215056031700241155ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/000077500000000000000000000000001215056031700246735ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/000077500000000000000000000000001215056031700267005ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/000077500000000000000000000000001215056031700303305ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotation/000077500000000000000000000000001215056031700325025ustar00rootroot00000000000000JacksonAnnotation.java000066400000000000000000000012171215056031700367120ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Meta-annotation (annotations used on other annotations) * used for marking all annotations that are * part of Jackson package. Can be used for recognizing all * Jackson annotations generically, and in future also for * passing other generic annotation configuration. */ @Target({ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface JacksonAnnotation { // for now, a pure tag annotation, no parameters } JacksonAnnotationsInside.java000066400000000000000000000014071215056031700402320ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Meta-annotation (annotations used on other annotations) * used for indicating that instead of using target annotation * (annotation annotated with this annotation), * Jackson should use meta-annotations it has. * This can be useful in creating "combo-annotations" by having * a container annotation, which needs to be annotated with this * annotation as well as all annotations it 'contains'. * * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JacksonAnnotationsInside { } JacksonInject.java000066400000000000000000000020011215056031700360040ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import com.fasterxml.jackson.annotation.JacksonAnnotation; /** * Jackson-specific annotation used for indicating that value of * annotated property will be "injected", i.e. set based on value * configured by ObjectMapper (usually on per-call basis). * Usually property is not deserialized from JSON, although it possible * to have injected value as default and still allow optional override * from JSON. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JacksonInject { /** * Logical id of the value to inject; if not specified (or specified * as empty String), will use id based on declared type of property. */ public String value() default ""; } JsonAnyGetter.java000066400000000000000000000015401215056031700360220ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that can be used to define a non-static, * no-argument method or member field as something of a reverse of * {@link JsonAnySetter} method; basically being used like a * getter but such that contents of the returned Map (type must be * {@link java.util.Map}) are serialized as if they were actual properties * of the bean that contains method/field with this annotations. * As with {@link JsonAnySetter}, only one property should be annotated * with this annotation. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonAnyGetter { } JsonAnySetter.java000066400000000000000000000015731215056031700360440ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that can be used to define a non-static, * two-argument method (first argument name of property, second value * to set), to be used as a "fallback" handler * for all otherwise unrecognized properties found from JSON content. * It is similar to {@link javax.xml.bind.annotation.XmlAnyElement} * in behavior; and can only be used to denote a single property * per type. *

* If used, all otherwise unmapped key-value pairs from JSON Object values * are added to the property (of type Map or bean). */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonAnySetter { } JsonAutoDetect.java000066400000000000000000000106241215056031700361640ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Member; import java.lang.reflect.Modifier; /** * Class annotation that can be used to define which kinds of Methods * are to be detected by auto-detection. * Auto-detection means using name conventions * and/or signature templates to find methods to use for data binding. * For example, so-called "getters" can be auto-detected by looking for * public member methods that return a value, do not take argument, * and have prefix "get" in their name. *

* Pseudo-value NONE means that all auto-detection is disabled * for the specific class that annotation is applied to (including * its super-types, but only when resolving that class). * Pseudo-value ALWAYS means that auto-detection is enabled * for all method types for the class in similar way. *

* The default value is ALWAYS: that is, by default, auto-detection * is enabled for all classes unless instructed otherwise. *

* Starting with version 1.5, it is also possible to use more fine-grained * definitions, to basically define minimum visibility level needed. Defaults * are different for different types (getters need to be public; setters can * have any access modifier, for example). */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonAutoDetect { /** * Enumeration for possible visibility thresholds (minimum visibility) * that can be used to limit which methods (and fields) are * auto-detected. */ public enum Visibility { /** * Value that means that all kinds of access modifiers are acceptable, * from private to public. */ ANY, /** * Value that means that any other access modifier other than 'private' * is considered auto-detectable. */ NON_PRIVATE, /** * Value that means access modifiers 'protected' and 'public' are * auto-detectable (and 'private' and "package access" == no modifiers * are not) */ PROTECTED_AND_PUBLIC, /** * Value to indicate that only 'public' access modifier is considered * auto-detectable. */ PUBLIC_ONLY, /** * Value that indicates that no access modifiers are auto-detectable: * this can be used to explicitly disable auto-detection for specified * types. */ NONE, /** * Value that indicates that default visibility level (whatever it is, * depends on context) is to be used. This usually means that inherited * value (from parent visibility settings) is to be used. */ DEFAULT; public boolean isVisible(Member m) { switch (this) { case ANY: return true; case NONE: return false; case NON_PRIVATE: return !Modifier.isPrivate(m.getModifiers()); case PROTECTED_AND_PUBLIC: if (Modifier.isProtected(m.getModifiers())) { return true; } // fall through to public case: case PUBLIC_ONLY: return Modifier.isPublic(m.getModifiers()); default: return false; } } } /** * Minimum visibility required for auto-detecting regular getter methods. */ Visibility getterVisibility() default Visibility.DEFAULT; /** * Minimum visibility required for auto-detecting is-getter methods. */ Visibility isGetterVisibility() default Visibility.DEFAULT; /** * Minimum visibility required for auto-detecting setter methods. */ Visibility setterVisibility() default Visibility.DEFAULT; /** * Minimum visibility required for auto-detecting Creator methods, * except for no-argument constructors (which are always detected * no matter what). */ Visibility creatorVisibility() default Visibility.DEFAULT; /** * Minimum visibility required for auto-detecting member fields. */ Visibility fieldVisibility() default Visibility.DEFAULT; } JsonBackReference.java000066400000000000000000000033151215056031700366010ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation used to indicate that associated property is part of * two-way linkage between fields; and that its role is "child" (or "back") link. * Value type of the property must be a bean: it can not be a Collection, Map, * Array or enumeration. * Linkage is handled such that the property * annotated with this annotation is not serialized; and during deserialization, * its value is set to instance that has the "managed" (forward) link. *

* All references have logical name to allow handling multiple linkages; typical case * would be that where nodes have both parent/child and sibling linkages. If so, * pairs of references should be named differently. * It is an error for a class to have multiple back references with same name, * even if types pointed are different. *

* Note: only methods and fields can be annotated with this annotation: constructor * arguments should NOT be annotated, as they can not be either managed or back * references. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonBackReference { /** * Logical have for the reference property pair; used to link managed and * back references. Default name can be used if there is just single * reference pair (for example, node class that just has parent/child linkage, * consisting of one managed reference and matching back reference) */ public String value() default "defaultReference"; } JsonCreator.java000066400000000000000000000025401215056031700355200ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that can be used to define constructors and factory * methods as one to use for instantiating new instances of the associated * class. *

* NOTE: when annotating creator methods (constructors, factory methods), * method must either be: *

* Also note that all {@link JsonProperty} annotations MUST use actual name * (NOT empty String for "default"): this because Java bytecode does not * retain names of method or constructor arguments. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonCreator { // no values, since there's no property } JsonFilter.java000066400000000000000000000020071215056031700353440ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation used to indicate which logical filter is to be used * for filtering out properties of type (class) annotated; * association made by this annotation declaring ids of filters, * and com.fasterxml.jackson.databind.ObjectMapper (or objects * it delegates to) providing matching filters by id. *

* Filters to use are usually of type * com.fasterxml.jackson.databind.ser.BeanPropertyFilter and * are registered through com.fasterxml.jackson.databind.ObjectMapper */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @com.fasterxml.jackson.annotation.JacksonAnnotation public @interface JsonFilter { /** * Id of filter to use; if empty String (""), no filter is to be used. */ public String value(); } JsonFormat.java000066400000000000000000000207131215056031700353530ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Locale; import java.util.TimeZone; /** * General-purpose annotation used for configuring details of how * values of properties are to be serialized. * Unlike most other Jackson annotations, annotation does not * have specific universal interpretation: instead, effect depends on datatype * of property being annotated (or more specifically, deserializer * and serializer being used). *

* Common uses include choosing between alternate representations -- for example, * whether {@link java.util.Date} is to be serialized as number (Java timestamp) * or String (such as ISO-8601 compatible time value) -- as well as configuring * exact details with {@link #pattern} property. *

* As of Jackson 2.1, known special handling include: *

* Jackson 2.1 added following new features: * * * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonFormat { /** * Value that indicates that default {@link java.util.Locale} * (from deserialization or serialization context) should be used: * annotation does not define value to use. */ public final static String DEFAULT_LOCALE = "##default"; /** * Value that indicates that default {@link java.util.TimeZone} * (from deserialization or serialization context) should be used: * annotation does not define value to use. */ public final static String DEFAULT_TIMEZONE = "##default"; /** * Datatype-specific additional piece of configuration that may be used * to further refine formatting aspects. This may, for example, determine * low-level format String used for {@link java.util.Date} serialization; * however, exact use is determined by specific JsonSerializer */ public String pattern() default ""; /** * Structure to use for serialization: definition of mapping depends on datatype, * but usually has straight-forward counterpart in data format (JSON). * Note that commonly only a subset of shapes is available; and if 'invalid' value * is chosen, defaults are usually used. */ public Shape shape() default Shape.ANY; /** * {@link java.util.Locale} to use for serialization (if needed). * Special value of {@link #DEFAULT_LOCALE} * can be used to mean "just use the default", where default is specified * by the serialization context, which in turn defaults to system * defaults ({@link java.util.Locale#getDefault()}) unless explicitly * set to another locale. */ public String locale() default DEFAULT_LOCALE; /** * {@link java.util.TimeZone} to use for serialization (if needed). * Special value of {@link #DEFAULT_TIMEZONE} * can be used to mean "just use the default", where default is specified * by the serialization context, which in turn defaults to system * defaults ({@link java.util.TimeZone#getDefault()}) unless explicitly * set to another locale. */ public String timezone() default DEFAULT_TIMEZONE; /* /********************************************************** /* Value enumeration(s), value class(es) /********************************************************** */ /** * Value enumeration used for indicating preferred Shape; translates * loosely to JSON types, with some extra values to indicate less precise * choices (i.e. allowing one of multiple actual shapes) */ public enum Shape { /** * Marker enum value that indicates "default" (or "whatever") choice; needed * since Annotations can not have null values for enums. */ ANY, /** * Value that indicates shape should not be structural (that is, not * {@link #ARRAY} or {@link #OBJECT}, but can be any other shape. */ SCALAR, /** * Value that indicates that (JSON) Array type should be used. */ ARRAY, /** * Value that indicates that (JSON) Object type should be used. */ OBJECT, /** * Value that indicates that a numeric (JSON) type should be used * (but does not specify whether integer or floating-point representation * should be used) */ NUMBER, /** * Value that indicates that floating-point numeric type should be used */ NUMBER_FLOAT, /** * Value that indicates that integer number type should be used * (and not {@link #NUMBER_FLOAT}). */ NUMBER_INT, /** * Value that indicates that (JSON) String type should be used. */ STRING, /** * Value that indicates that (JSON) boolean type * (true, false) should be used. */ BOOLEAN ; public boolean isNumeric() { return (this == NUMBER) || (this == NUMBER_INT) || (this == NUMBER_FLOAT); } public boolean isStructured() { return (this == OBJECT) || (this == ARRAY); } } /** * Helper class used to contain information from a single {@link JsonFormat} * annotation. */ public static class Value { private final String pattern; private final Shape shape; private final Locale locale; private final TimeZone timezone; public Value() { this("", Shape.ANY, "", ""); } public Value(JsonFormat ann) { this(ann.pattern(), ann.shape(), ann.locale(), ann.timezone()); } public Value(String p, Shape sh, String localeStr, String tzStr) { this(p, sh ,(localeStr == null || localeStr.length() == 0 || DEFAULT_LOCALE.equals(localeStr)) ? null : new Locale(localeStr) ,(tzStr == null || tzStr.length() == 0 || DEFAULT_TIMEZONE.equals(tzStr)) ? null : TimeZone.getTimeZone(tzStr) ); } /** * @since 2.1 */ public Value(String p, Shape sh, Locale l, TimeZone tz) { pattern = p; shape = sh; locale = l; timezone = tz; } /** * @since 2.1 */ public Value withPattern(String p) { return new Value(p, shape, locale, timezone); } /** * @since 2.1 */ public Value withShape(Shape s) { return new Value(pattern, s, locale, timezone); } /** * @since 2.1 */ public Value withLocale(Locale l) { return new Value(pattern, shape, l, timezone); } /** * @since 2.1 */ public Value withTimeZone(TimeZone tz) { return new Value(pattern, shape, locale, tz); } public String getPattern() { return pattern; } public Shape getShape() { return shape; } public Locale getLocale() { return locale; } public TimeZone getTimeZone() { return timezone; } } } JsonGetter.java000066400000000000000000000022211215056031700353470ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that can be used to define a non-static, * no-argument value-returning (non-void) method to be used as a "getter" * for a logical property. * It can be used as an alternative to more general * {@link JsonProperty} annotation (which is the recommended choice in * general case). *

* Getter means that when serializing Object instance of class that has * this method (possibly inherited from a super class), a call is made * through the method, and return value will be serialized as value of * the property. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonGetter { /** * Defines name of the logical property this * method is used to access ("get"); empty String means that * name should be derived from the underlying method (using * standard Bean name detection rules) */ String value() default ""; } JsonIdentityInfo.java000066400000000000000000000061321215056031700365270ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation used for indicating that values of annotated type * or property should be serializing so that instances either * contain additional object identifier (in addition actual object * properties), or as a reference that consists of an object id * that refers to a full serialization. In practice this is done * by serializing the first instance as full object and object * identity, and other references to the object as reference values. *

* There are two main approaches to generating object identifier: * either using a generator (either one of standard ones, or a custom * generator), or using a value of a property. The latter case is * indicated by using a placeholder generator marker * {@link ObjectIdGenerators.PropertyGenerator}; former by using explicit generator. * Object id has to be serialized as a property in case of POJOs; * object identity is currently NOT support for JSON Array types * (Java arrays or Lists) or Java Map types. *

* Finally, note that generator type of {@link ObjectIdGenerators.None} * indicates that no Object Id should be included or used: it is included * to allow suppressing Object Ids using mix-in annotations. * * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIdentityInfo { /** * Name of JSON property in which Object Id will reside: also, * if "from property" marker generator is used, identifies * property that will be accessed to get type id. * If a property is used, name must match its external * name (one defined by annotation, or derived from accessor * name as per Java Bean Introspection rules). *

* Default value is @id. */ public String property() default "@id"; /** * Generator to use for producing Object Identifier for objects: * either one of pre-defined generators from * {@link ObjectIdGenerator}, or a custom generator. * Defined as class to instantiate. *

* Note that special type * {@link ObjectIdGenerators.None} * can be used to disable inclusion of Object Ids. */ public Class> generator(); /** * Scope is used to define applicability of an Object Id: all ids * must be unique within their scope; where scope is defined * as combination of this value and generator type. * Comparison is simple equivalence, meaning that both type * generator type and scope class must be the same. *

* Scope is used for determining how many generators are needed; * more than one scope is typically only needed if external Object Ids * have overlapping value domains (i.e. are only unique within some * limited scope) */ public Class scope() default Object.class; } JsonIdentityReference.java000066400000000000000000000024111215056031700375260ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Optional annotation that can be used for customizing details of a reference * to Objects for which "Object Identity" is enabled (see {@link JsonIdentityInfo}). * The main use case is that of enforcing use of Object Id even for the first * time an Object is referenced, instead of first instance being serialized * as full POJO. * * @since 2.1 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIdentityReference { /** * Marker to indicate whether all referenced values are to * be serialized as ids (true); or by serializing the * first encountered reference as POJO and only then as id (false). *

* Note that if value of 'true' is used, deserialization may require * additional contextual information, and possibly using a custom * id resolver -- the default handling may not be sufficient. * * @since 2.1 */ public boolean alwaysAsId() default false; } JsonIgnore.java000066400000000000000000000053151215056031700353470ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that indicates that the annotated method or field is to be * ignored by introspection-based * serialization and deserialization functionality. That is, it should * not be consider a "getter", "setter" or "creator". *

* In addition, starting with Jackson 1.9, if this is the only annotation * associated with a property, it will also cause cause the whole * property to be ignored: that is, if setter has this annotation and * getter has no annotations, getter is also effectively ignored. * It is still possible for different accessors to use different * annotations; so if only "getter" is to be ignored, other accessors * (setter or field) would need explicit annotation to prevent * ignoral (usually {@link JsonProperty}). *

* For example, a "getter" method that would otherwise denote * a property (like, say, "getValue" to suggest property "value") * to serialize, would be ignored and no such property would * be output unless another annotation defines alternative method to use. *

* Before version 1.9, this annotation worked purely on method-by-method (or field-by-field) * basis; annotation on one method or field did not imply ignoring other methods * or fields. However, with version 1.9 and above, annotations associated * with various accessors (getter, setter, field, constructor parameter) of * a logical property are combined; meaning that annotations in one (say, setter) * can have effects on all of them (if getter or field has nothing indicating * otherwise). *

* Annotation is usually used just a like a marker annotation, that * is, without explicitly defining 'value' argument (which defaults * to true): but argument can be explicitly defined. * This can be done to override an existing JsonIgnore by explicitly * defining one with 'false' argument. *

* Annotation is similar to {@link javax.xml.bind.annotation.XmlTransient} */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIgnore { /** * Optional argument that defines whether this annotation is active * or not. The only use for value 'false' if for overriding purposes * (which is not needed often); most likely it is needed for use * with "mix-in annotations" (aka "annotation overrides"). * For most cases, however, default value of "true" is just fine * and should be omitted. */ boolean value() default true; } JsonIgnoreProperties.java000066400000000000000000000035631215056031700374270ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation that can be used to either suppress serialization of * properties (during serialization), or ignore processing of * JSON properties read (during deserialization). *

* Example: *

 * // to prevent specified fields from being serialized or deserialized
 * // (i.e. not include in JSON output; or being set even if they were included)
 * @JsonIgnoreProperties({ "internalId", "secretKey" })
 * // To ignore any unknown properties in JSON input without exception:
 * @JsonIgnoreProperties(ignoreUnknown=true)
 *
*

* Starting with 2.0, this annotation can be applied both to classes and * to properties. If used for both, actual set will be union of all * ignorals: that is, you can only add properties to ignore, not remove * or override. So you can not remove properties to ignore using * per-property annotation. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIgnoreProperties { /** * Names of properties to ignore. */ public String[] value() default { }; /** * Property that defines whether it is ok to just ignore any * unrecognized properties during deserialization. * If true, all properties that are unrecognized -- that is, * there are no setters or creators that accept them -- are * ignored without warnings (although handlers for unknown * properties, if any, will still be called) without * exception. *

* Does not have any effect on serialization. */ public boolean ignoreUnknown() default false; } JsonIgnoreType.java000066400000000000000000000021051215056031700362030ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Marker annotation that indicates that all properties of annotated * type are to be ignored during serialization and deserialization. *

* Note: annotation does have boolean 'value' property (which defaults * to 'true'), so that it is actually possible to override value * using mix-in annotations. */ @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation public @interface JsonIgnoreType { /** * Optional argument that defines whether this annotation is active * or not. The only use for value 'false' if for overriding purposes * (which is not needed often); most likely it is needed for use * with "mix-in annotations" ("annotation overrides"). * For most cases, however, default value of "true" is just fine * and should be omitted. */ boolean value() default true; } JsonInclude.java000066400000000000000000000066551215056031700355170ustar00rootroot00000000000000jackson-annotations-jackson-annotations-2.2.2/src/main/java/com/fasterxml/jackson/annotationpackage com.fasterxml.jackson.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Annotation used to indicate when value of the annotated property (when * used for a field, method or constructor parameter), or all * properties of the annotated class, is to be serialized. * Without annotation property values are always included, but by using * this annotation one can specify simple exclusion rules to reduce * amount of properties to write out. * * @since 2.0 */ @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME) @com.fasterxml.jackson.annotation.JacksonAnnotation public @interface JsonInclude { /** * Inclusion rule to use. */ public Include value() default Include.ALWAYS; /* /********************************************************** /* Value enumerations needed /********************************************************** */ /** * Enumeration used with {@link JsonInclude} * to define which properties * of Java Beans are to be included in serialization. *

* Note: Jackson 1.x had similarly named ("Inclusion") enumeration included * in JsonSerialize annotation: it is not deprecated * and this value used instead. */ public enum Include { /** * Value that indicates that property is to be always included, * independent of value of the property. */ ALWAYS, /** * Value that indicates that only properties with non-null * values are to be included. */ NON_NULL, /** * Value that indicates that only properties that have values * that differ from default settings (meaning values they have * when Bean is constructed with its no-arguments constructor) * are to be included. Value is generally not useful with * {@link java.util.Map}s, since they have no default values; * and if used, works same as {@link #ALWAYS}. */ NON_DEFAULT, /** * Value that indicates that only properties that have values * that values that are null or what is considered empty are * not to be included. *

* Default emptiness is defined for following type: *