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 "";
/**
* Whether matching input value is used for annotated property or not;
* if disabled (`OptBoolean.FALSE`), input value (if any) will be ignored;
* otherwise it will override injected value.
*
* Default is `OptBoolean.DEFAULT`, which translates to `OptBoolean.TRUE`: this is
* for backwards compatibility (2.8 and earlier always allow binding input value).
*
* @since 2.9
*/
public OptBoolean useInput() default OptBoolean.DEFAULT;
/*
/**********************************************************
/* Value class used to enclose information, allow for
/* merging of layered configuration settings, and eventually
/* decouple higher level handling from Annotation types
/* (which can not be implemented etc)
/**********************************************************
*/
/**
* Helper class used to contain information from a single {@link JacksonInject}
* annotation, as well as to provide possible overrides from non-annotation sources.
*
* @since 2.9
*/
public static class Value
implements JacksonAnnotationValue
* Examples:
*
* As with {@link JsonAnySetter}, only one property should be annotated
* with this annotation; if multiple methods are annotated, an exception
* may be thrown.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonAnyGetter
{
/**
* Optional argument that defines whether this annotation is active
* or not. The only use for value 'false' if for overriding purposes.
* Overriding may be necessary when used
* with "mix-in annotations" (aka "annotation overrides").
* For most cases, however, default value of "true" is just fine
* and should be omitted.
*
* @since 2.9
*/
boolean enabled() default true;
}
JsonAnySetter.java 0000664 0000000 0000000 00000002773 13231774410 0036062 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 logical "any setter" mutator --
* either using non-static
* two-argument method (first argument name of property, second value
* to set) or a field (of type {@link java.util.Map} or POJO) -
* 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 using mutator.
*
* NOTE: ability to annotated fields was added in version 2.8; earlier only
* methods could be annotated.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonAnySetter
{
/**
* Optional argument that defines whether this annotation is active
* or not. The only use for value 'false' if for overriding purposes.
* Overriding may be necessary when used
* with "mix-in annotations" (aka "annotation overrides").
* For most cases, however, default value of "true" is just fine
* and should be omitted.
*
* @since 2.9
*/
boolean enabled() default true;
}
JsonAutoDetect.java 0000664 0000000 0000000 00000033517 13231774410 0036205 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.*;
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, and with what minimum access level.
* 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.
*
* Default setting for all accessors is {@link Visibility#DEFAULT}, which
* in turn means that the global defaults are used. Defaults
* are different for different accessor types (getters need to be public;
* setters can have any access modifier, for example).
* If you assign different {@link Visibility} type then it will override
* global defaults: for example, to require that all setters must be public,
* you would use:
*
* 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";
}
JsonClassDescription.java 0000664 0000000 0000000 00000001311 13231774410 0037400 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation used to define a human readable description for annotated
* type (class).
* Currently used to populate the description field in generated JSON
* Schemas.
*
* @since 2.7
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@JacksonAnnotation
public @interface JsonClassDescription
{
/**
* Defines a human readable description of the class.
*/
String value() default "";
}
JsonCreator.java 0000664 0000000 0000000 00000010175 13231774410 0035536 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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:
*
* One common use case is to use a delegating Creator to construct instances from
* scalar values (like
* NOTE: As of Jackson 2.6, use of {@link JsonProperty#required()} is supported
* for Creator methods (but not necessarily for regular setters or fields!).
*
* @see JsonCreator
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonCreator
{
/**
* Property that is used to indicate how argument(s) is/are bound for creator,
* in cases there may be multiple alternatives. Currently the one case is that
* of a single-argument creator method, for which both so-called "delegating" and
* "property-based" bindings are possible: since
* delegating mode can not be used for multi-argument creators, the only choice
* there is "property-based" mode.
* Check {@link Mode} for more complete explanation of possible choices.
*
* Default value of {@link Mode#DEFAULT} means that caller is to use standard
* heuristics for choosing mode to use.
*
* @since 2.5
*/
public Mode mode() default Mode.DEFAULT;
/**
* @since 2.5
*/
public enum Mode {
/**
* Pseudo-mode that indicates that caller is to use default heuristics for
* choosing mode to use. This typically favors use of delegating mode for
* single-argument creators that take structured types.
*/
DEFAULT,
/**
* Mode that indicates that if creator takes a single argument, the whole incoming
* data value is to be bound into declared type of that argument; this "delegate"
* value is then passed as the argument to creator.
*/
DELEGATING,
/**
* Mode that indicates that the argument(s) for creator are to be bound from matching
* properties of incoming Object value, using creator argument names (explicit or implicit)
* to match incoming Object properties to arguments.
*
* Note that this mode is currently (2.5) always used for multiple-argument creators;
* the only ambiguous case is that of a single-argument creator.
*/
PROPERTIES,
/**
* Pseudo-mode that indicates that creator is not to be used. This can be used as a result
* value for explicit disabling, usually either by custom annotation introspector,
* or by annotation mix-ins (for example when choosing different creator).
*/
DISABLED
}
}
JsonEnumDefaultValue.java 0000664 0000000 0000000 00000001376 13231774410 0037350 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 default value
* used when trying to deserialize unknown Enum values.
*
* This annotation is only applicable when the
* If the more than one enum value is marked with this annotation,
* the first one to be detected will be used. Which one exactly is undetermined.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonEnumDefaultValue
{
}
JsonFilter.java 0000664 0000000 0000000 00000002311 13231774410 0035355 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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
* Filters to use are usually of type
*
* Since 2.3, this annotation can also be used on properties (fields, methods,
* constructor parameters).
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE,
ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER // new in 2.3
})
@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.java 0000664 0000000 0000000 00000067447 13231774410 0035405 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.*;
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.6, known special handling includes:
*
* NOTE: default here does NOT mean JVM defaults but Jackson databindings
* default, usually UTC, but may be changed on
* Note that underlying default setting depends on datatype (or more precisely
* deserializer for it): for most date/time types, default is for leniency
* to be enabled.
*
* @since 2.9
*/
public OptBoolean lenient() default OptBoolean.DEFAULT;
/**
* Set of {@link JsonFormat.Feature}s to explicitly enable with respect
* to handling of annotated property. This will have precedence over possible
* global configuration.
*
* @since 2.6
*/
public JsonFormat.Feature[] with() default { };
/**
* Set of {@link JsonFormat.Feature}s to explicitly disable with respect
* to handling of annotated property. This will have precedence over possible
* global configuration.
*
* @since 2.6
*/
public JsonFormat.Feature[] without() default { };
/*
/**********************************************************
/* 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 "whatever" choice, meaning that annotation
* does NOT specify shape to use.
* Note that this is different from {@link Shape#NATURAL}, which
* specifically instructs use of the "natural" shape for datatype.
*/
ANY,
/**
* Marker enum value that indicates the "default" choice for given datatype;
* for example, JSON String for {@link java.lang.String}, or JSON Number
* for Java numbers.
* Note that this is different from {@link Shape#ANY} in that this is actual
* explicit choice that overrides possible default settings.
*
* @since 2.8
*/
NATURAL,
/**
* 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);
}
}
/**
* Set of features that can be enabled/disabled for property annotated.
* These often relate to specific
* Note that whether specific setting has an effect depends on whether
*
* NOTE: starting with 2.9 can also effect Enum handling (and potentially other
* places where case-insensitive property values are accepted).
*
* @since 2.8
*/
ACCEPT_CASE_INSENSITIVE_PROPERTIES,
/**
* Override for
* NOTE: due to limitations of "old" JDK date/time types (that is,
* {@link java.util.Date} and {@link java.util.Calendar}), this setting is only
* applicable to
* 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.java 0000664 0000000 0000000 00000006547 13231774410 0036554 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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
* Note that special type
* {@link ObjectIdGenerators.None}
* can be used to disable inclusion of Object Ids.
*/
public Class extends ObjectIdGenerator>> generator();
/**
* Resolver to use for producing POJO from Object Identifier.
*
* Default value is {@link SimpleObjectIdResolver}
*
* @since 2.4
*/
public Class extends ObjectIdResolver> resolver() default SimpleObjectIdResolver.class;
/**
* 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.java 0000664 0000000 0000000 00000002410 13231774410 0037540 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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.java 0000664 0000000 0000000 00000005573 13231774410 0035370 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 logical property that
* the accessor (field, getter/setter method or Creator parameter
* [of {@link JsonCreator}-annotated constructor or factory method])
* is to be ignored by introspection-based
* serialization and deserialization functionality.
*
* Annotation only needs to be added to one of the accessors (often
* getter method, but may be setter, field or creator parameter),
* if the complete removal of the property is desired.
* However: if only particular accessor is to be ignored (for example,
* when ignoring one of potentially conflicting setter methods),
* this can be done by annotating other not-to-be-ignored accessors
* with {@link JsonProperty} (or its equivalents). This is considered
* so-called "split property" case and allows definitions of
* "read-only" (read from input into POJO) and "write-only" (write
* in output but ignore on output)
*
* 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.
*
* When ignoring the whole property, the default behavior if encountering
* such property in input is to ignore it without exception; but if there
* is a {@link JsonAnySetter} it will be called instead. Either way,
* no exception will be thrown.
*
* Annotation is usually used just a like a marker annotation, that
* is, without explicitly defining 'value' argument (which defaults
* to
* Example:
*
* 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;
/**
* Property that can be enabled to allow "getters" to be used (that is,
* prevent ignoral of getters for properties listed in {@link #value()}).
* This is commonly set to support defining "read-only" properties; ones
* for which there is a getter, but no matching setter: in this case,
* properties should be ignored for deserialization but NOT serialization.
* Another way to think about this setting is that setting it to `true`
* will "disable" ignoring of getters.
*
* Default value is `false`, which means that getters with matching names
* will be ignored.
*
* @since 2.6
*/
public boolean allowGetters() default false;
/**
* Property that can be enabled to allow "setters" to be used (that is,
* prevent ignoral of setters for properties listed in {@link #value()}).
* This could be used to specify "write-only" properties; ones
* that should not be serialized out, but that may be provided in for
* deserialization.
* Another way to think about this setting is that setting it to `true`
* will "disable" ignoring of setters.
*
* Default value is `false`, which means that setters with matching names
* will be ignored.
*
* @since 2.6
*/
public boolean allowSetters() default false;
/*
/**********************************************************
/* Value class used to enclose information, allow for
/* merging of layered configuration settings.
/**********************************************************
*/
/**
* Helper class used to contain information from a single {@link JsonIgnoreProperties}
* annotation, as well as to provide possible overrides from non-annotation sources.
*
* @since 2.8
*/
public static class Value
implements JacksonAnnotationValue
* 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.java 0000664 0000000 0000000 00000047274 13231774410 0035534 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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.
*
* Note that the main inclusion criteria (one annotated with {@link #value})
* is checked on Java object level, for the annotated type,
* and NOT on JSON output -- so even with {@link Include#NON_NULL}
* it is possible that JSON null values are output, if object reference
* in question is not `null`. An example is {@link java.util.concurrent.atomic.AtomicReference}
* instance constructed to reference
* To base inclusion on value of contained value(s), you will typically also need
* to specify {@link #content()} annotation; for example, specifying only
* {@link #value} as {@link Include#NON_EMPTY} for a {link java.util.Map} would
* exclude
* In addition to `Map`s, `content` concept is also supported for referential
* types (like {@link java.util.concurrent.atomic.AtomicReference}).
* Note that `content` is NOT currently (as of Jackson 2.9) supported for
* arrays or {@link java.util.Collection}s, but supported may be added in
* future versions.
*
* @since 2.0
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD,
ElementType.TYPE, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonInclude
{
/**
* Inclusion rule to use for instances (values) of types (Classes) or
* properties annotated; defaults to {@link Include#ALWAYS}.
*/
public Include value() default Include.ALWAYS;
/**
* Inclusion rule to use for entries ("content") of annotated
* {@link java.util.Map}s and referential types (like
* {@link java.util.concurrent.atomic.AtomicReference});
* defaults to {@link Include#ALWAYS}.
*
* @since 2.5
*/
public Include content() default Include.ALWAYS;
/**
* Specifies type of "Filter Object" to use in case
* {@link #value} is {@link JsonInclude.Include#CUSTOM}:
* if so, an instance is created by calling
* Default emptiness for all types includes:
*
* Note that this default handling can be overridden by custom
*
* Compatibility note: Jackson 2.6 included a wider range of "empty" values than
* either earlier (up to 2.5) or later (2.7 and beyond) types; specifically:
*
* When used for a POJO, definition is that only values that differ from
* the default values of POJO properties are included. This is done
* by creating an instance of POJO using zero-argument constructor,
* and accessing property values: value is used as the default value
* by using
* When NOT used for a POJO (that is, as a global default, or as property
* override), definition is such that:
*
* 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 too have multiple managed 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.
*
* @author tatu
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonManagedReference
{
/**
* 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";
}
JsonMerge.java 0000664 0000000 0000000 00000004663 13231774410 0035203 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 to specify whether annotated property value should use "merging" approach,
* in which current value is first accessed (with a getter or field) and then modified
* with incoming data, or not: if not, assignment happens without considering current state.
*
* Merging is only option if there is a way to introspect current state:
* if there is accessor (getter, field) to use.
* Merging can not be enabled if no accessor exists
* or if assignment occurs using a Creator setter (constructor
* or factory method), since there is no instance with state to introspect.
* Merging also only has actual effect for structured types where there is an
* obvious way to update a state (for example, POJOs have default values for properties,
* and {@link java.util.Collection}s and {@link java.util.Map}s may have existing
* elements; whereas scalar types do not such state: an
* Merging is applied by using a deserialization method that accepts existing state
* as an argument: it is then up to
* Note that use of merging usually adds some processing overhead since it adds
* an extra step of accessing the current state before assignment.
*
* Note also that "root values" (values directly deserialized and not reached
* via POJO properties) can not use this annotation; instead,
* Default value is {@link OptBoolean#TRUE}, that is, merging is enabled.
*
* @since 2.9
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonMerge
{
/**
* Whether merging should or should not be enabled for the annotated property.
*/
OptBoolean value() default OptBoolean.TRUE;
}
JsonProperty.java 0000664 0000000 0000000 00000015025 13231774410 0035762 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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
* method as a "setter" or "getter" for a logical property
* (depending on its signature),
* or non-static object field to be used (serialized, deserialized) as
* a logical property.
*
* Default value ("") indicates that the field name is used
* as the property name without any modifications, but it
* can be specified to non-empty value to specify different
* name. Property name refers to name used externally, as
* the field name in JSON objects.
*
* Starting with Jackson 2.6 this annotation may also be
* used to change serialization of
* Note that as of 2.6, this property is only used for Creator
* Properties, to ensure existence of property value in JSON:
* for other properties (ones injected using a setter or mutable
* field), no validation is performed. Support for those cases
* may be added in future.
* State of this property is exposed via introspection, and its
* value is typically used by Schema generators, such as one for
* JSON Schema.
*
* @since 2.0
*/
boolean required() default false;
/**
* Property that indicates numerical index of this property (relative
* to other properties specified for the Object). This index
* is typically used by binary formats, but may also be useful
* for schema languages and other tools.
*
* @since 2.4
*/
int index() default INDEX_UNKNOWN;
/**
* Property that may be used to document expected default value
* for the property: most often used as source information for generating
* schemas (like JSON Schema or protobuf/thrift schema), or documentation.
* It may also be used by Jackson extension modules; core jackson databind
* does not have any automated handling beyond simply exposing this
* value through bean property introspection.
*
* It is possible that in future this annotation could be used for value
* defaulting, and especially for default values of Creator properties,
* since they support {@link #required()} in 2.6 and above.
*
* @since 2.5
*/
String defaultValue() default "";
/**
* Optional property that may be used to change the way visibility of
* accessors (getter, field-as-getter) and mutators (contructor parameter,
* setter, field-as-setter) is determined, either so that otherwise
* non-visible accessors (like private getters) may be used; or that
* otherwise visible accessors are ignored.
*
* Default value os {@link Access#AUTO} which means that access is determined
* solely based on visibility and other annotations.
*
* @since 2.6
*/
Access access() default Access.AUTO;
/**
* Various options for {@link #access} property, specifying how property
* may be accessed during serialization ("read") and deserialization ("write")
* (note that the direction of read and write is from perspective of the property,
* not from external data format: this may be confusing in some contexts).
*
* Note that while this annotation modifies access to annotated property,
* its effects may be further overridden by {@link JsonIgnore} property:
* if both annotations are present on an accessors, {@link JsonIgnore}
* has precedence over this property.
* This annotation property is, however, preferred over use of "split"
* {@link JsonIgnore}/
* Examples:
*
* This annotation may or may not have effect on deserialization: for basic JSON
* handling there is no effect, but for other supported data types (or structural
* conventions) there may be.
*
* NOTE: annotation is allowed for properties, starting with 2.4, mostly to support
* alphabetic ordering of {@link java.util.Map} entries.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE,
ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonPropertyOrder
{
/**
* Order in which properties of annotated object are to be serialized in.
*/
public String[] value() default { };
/**
* Property that defines what to do regarding ordering of properties
* not explicitly included in annotation instance. If set to true,
* they will be alphabetically ordered; if false, order is
* undefined (default setting)
*/
public boolean alphabetic() default false;
}
JsonRawValue.java 0000664 0000000 0000000 00000002325 13231774410 0035663 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 should be serialized by including literal String value
* of the property as is, without quoting of characters.
* This can be useful for injecting values already serialized in JSON or
* passing javascript function definitions from server to a javascript client.
*
* Warning: the resulting JSON stream may be invalid depending on your input value.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonRawValue
{
/**
* 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;
}
JsonRootName.java 0000664 0000000 0000000 00000003201 13231774410 0035653 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 similar to {@link javax.xml.bind.annotation.XmlRootElement},
* used to indicate name to use for root-level wrapping, if wrapping is
* enabled. Annotation itself does not indicate that wrapping should
* be used; but if it is, name used for serialization should be name
* specified here, and deserializer will expect the name as well.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@com.fasterxml.jackson.annotation.JacksonAnnotation
public @interface JsonRootName
{
/**
* Root name to use if root-level wrapping is enabled. For data formats
* that use composite names (XML), this is the "local part" of the name
* to use.
*/
public String value();
/**
* Optional namespace to use with data formats that support such
* concept (specifically XML); if so, used with {@link #value} to
* construct fully-qualified name.
*
* @since 2.4
*/
public String namespace() default "";
/*
* Optional marker property that can be defined as
* Note that value of
* NOTE: is not usually used in case property value is missing, unless
* data format specifies that there is defaulting which would result
* in an explicit null assignment.
*/
Nulls nulls() default Nulls.DEFAULT;
/**
* Specifies action to take when input to match into content value
* (of a {@link java.util.Collection}, {@link java.util.Map}, array,
* or referential value) contains explicit `null` value
* (if format has one) to bind.
* Default action, in absence of any explicit configuration,
* is usually {@link Nulls#SET}, meaning that the `null` is included as usual.
*/
Nulls contentNulls() default Nulls.DEFAULT;
/*
/**********************************************************
/* Value class used to enclose information, allow for
/* merging of layered configuration settings.
/**********************************************************
*/
/**
* Helper class used to contain information from a single {@link JsonSetter}
* annotation, as well as to provide possible overrides from non-annotation sources.
*
* @since 2.9
*/
public static class Value
implements JacksonAnnotationValue
* Note that just annotating a property or base type with this annotation does
* NOT enable polymorphic type handling: in addition, {@link JsonTypeInfo}
* or equivalent (such as enabling of so-called "default typing") annotation
* is needed, and only in such case is subtype information used.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD,
ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonSubTypes {
/**
* Subtypes of the annotated type (annotated class, or property value type
* associated with the annotated method). These will be checked recursively
* so that types can be defined by only including direct subtypes.
*/
public Type[] value();
/**
* Definition of a subtype, along with optional name. If name is missing, class
* of the type will be checked for {@link JsonTypeName} annotation; and if that
* is also missing or empty, a default
* name will be constructed by type id mechanism.
* Default name is usually based on class name.
*/
public @interface Type {
/**
* Class of the subtype
*/
public Class> value();
/**
* Logical type name used as the type identifier for the class
*/
public String name() default "";
}
}
JsonTypeId.java 0000664 0000000 0000000 00000002720 13231774410 0035332 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 on a property accessor
* (field, getter or setter, constructor parameter) to indicate that
* the property is to contain type id to use when including
* polymorphic type information.
* Annotation should only be used if the intent is to override
* generation of standard type id: if so, value of the property will be
* accessed during serialization and used as the type id.
*
* On deserialization annotation has no effect, as visibility of type id
* is governed by value of {@link JsonTypeInfo#visible}; properties with
* this annotation get no special handling.
*
* On serialization, this annotation will exclude property from being
* serialized along other properties; instead, its value is serialized
* as the type identifier. Since type identifier may be included in
* various places, it may still appear like 'normal' property (when using
* {@link JsonTypeInfo.As#PROPERTY}), but is more commonly embedded
* in a different place, as per inclusion rules (see {@link JsonTypeInfo}
* for details).
*
* @since 2.0
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonTypeId
{
}
JsonTypeInfo.java 0000664 0000000 0000000 00000032556 13231774410 0035703 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.*;
/**
* Annotation used for configuring details of if and how type information is
* used with JSON serialization and deserialization, to preserve information
* about actual class of Object instances. This is necessarily for polymorphic
* types, and may also be needed to link abstract declared types and matching
* concrete implementation.
*
* Some examples of typical annotations:
*
* This annotation can be used both for types (classes) and properties.
* If both exist, annotation on property has precedence, as it is
* considered more specific.
*
* When used for properties (fields, methods), this annotation applies
* to values: so when applied to structure types
* (like {@link java.util.Collection}, {@link java.util.Map}, arrays),
* will apply to contained values, not the container;
* for non-structured types there is no difference.
* This is identical to how JAXB handles type information
* annotations; and is chosen since it is the dominant use case.
* There is no per-property way to force type information to be included
* for type of container (structured type); for container types one has
* to use annotation for type declaration.
*
* Note on visibility of type identifier: by default, deserialization
* (use during reading of JSON) of type identifier
* is completely handled by Jackson, and is not passed to
* deserializers. However, if so desired,
* it is possible to define property
* On serialization side, Jackson will generate type id by itself,
* except if there is a property with name that matches
* {@link #property()}, in which case value of that property is
* used instead.
*
* NOTE: use of type id of "class name" with very general base type
* (such as {@link java.lang.Object} or {@link java.io.Serializable})
* can potentially open up security holes if deserializing content
* generated by untrusted sources. If content can not be trusted,
* it is necessary to either use "type name" as type id, or to
* limit possible types using other means.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE,
ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonTypeInfo
{
/*
/**********************************************************
/* Value enumerations used for properties
/**********************************************************
*/
/**
* Definition of different type identifiers that can be included in JSON
* during serialization, and used for deserialization.
*/
public enum Id {
/**
* This means that no explicit type metadata is included, and typing is
* purely done using contextual information possibly augmented with other
* annotations.
*/
NONE(null),
/**
* Means that fully-qualified Java class name is used as the type identifier.
*/
CLASS("@class"),
/**
* Means that Java class name with minimal path is used as the type identifier.
* Minimal means that only the class name, and that part of preceding Java
* package name is included that is needed to construct fully-qualified name
* given fully-qualified name of the declared supertype; additionally a single
* leading dot ('.') must be used to indicate that partial class name is used.
* For example, for supertype "com.foobar.Base", and concrete type
* "com.foo.Impl", only ".Impl" would be included; and for "com.foo.impl.Impl2"
* only ".impl.Impl2" would be included.
*
* If all related classes are in the same Java package, this option can reduce
* amount of type information overhead, especially for small types.
* However, please note that using this alternative is inherently risky since it
* assumes that the
* supertype can be reliably detected. Given that it is based on declared type
* (since ultimate supertype,
* Default choice for inclusion.
*/
PROPERTY,
/**
* Inclusion mechanism that wraps typed JSON value (POJO
* serialized as JSON) in
* a JSON Object that has a single entry,
* where field name is serialized type identifier,
* and value is the actual JSON value.
*
* Note: can only be used if type information can be serialized as
* String. This is true for standard type metadata types, but not
* necessarily for custom types.
*/
WRAPPER_OBJECT,
/**
* Inclusion mechanism that wraps typed JSON value (POJO
* serialized as JSON) in
* a 2-element JSON array: first element is the serialized
* type identifier, and second element the serialized POJO
* as JSON Object.
*/
WRAPPER_ARRAY,
/**
* Inclusion mechanism similar to
* Note that this behavior is quite similar to that of using {@link JsonTypeId}
* annotation;
* except that here
* Note that for type metadata type of {@link Id#CUSTOM},
* this setting may or may not have any effect.
*/
public As include() default As.PROPERTY;
/**
* Property names used when type inclusion method ({@link As#PROPERTY}) is used
* (or possibly when using type metadata of type {@link Id#CUSTOM}).
* If POJO itself has a property with same name, value of property
* will be set with type id metadata: if no such property exists, type id
* is only used for determining actual type.
*
* Default property name used if this property is not explicitly defined
* (or is set to empty
* Note that while this property allows specification of the default
* implementation to use, it does not help with structural issues that
* may arise if type information is missing. This means that most often
* this is used with type-name -based resolution, to cover cases
* where new sub-types are added, but base type is not changed to
* reference new sub-types.
*
* There are certain special values that indicate alternate behavior:
*
* Default value is false, meaning that Jackson handles and removes
* the type identifier from JSON content that is passed to
*
* Also note that annotation only applies if
*
* At most one accessor of a
* A typical usage is that of annotating
* Boolean argument is only used so that sub-classes can "disable"
* annotation if necessary.
*
* NOTE: when use for Java
* An example annotation would be:
*
* Starting with 2.9, it is also possible to use this annotation on
* POJO classes to indicate the default view(s) for properties of the
* type, unless overridden by per-property annotation.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD,
ElementType.PARAMETER, // since 2.5
ElementType.TYPE // since 2.9, to indicate "default view" for properties
})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonView {
/**
* View or views that annotated element is part of. Views are identified
* by classes, and use expected class inheritance relationship: child
* views contain all elements parent views have, for example.
*/
public Class>[] value() default { };
}
Nulls.java 0000664 0000000 0000000 00000002461 13231774410 0034401 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
/**
* Enumeration used with {@link JsonSetter} (for properties `nulls`
* and `contentNulls`)
* to define how explicit `null` values from input (if input format
* has the concept; JSON, for example does) are handled.
*/
public enum Nulls
{
/**
* Value that indicates that an input null should result in assignment
* of Java `null` value of matching property (except where deserializer
* indicates other "null value" by overriding
* Default implementation returns
* Note that actual type of 'context' is
*
* NOTE: {@link PropertyGenerator} applicability is limited in one case: it can only
* be used on polymorphic base types (ones indicated using {@link JsonTypeInfo} or
* default typing) via class annotations: property annotation will fail due to lack
* of access to property, needed to determine type of Object Id for deserialization.
* This limitation may be lifted in future versions but it is the limitation at least
* up to and including Jackson 2.9.
*/
public class ObjectIdGenerators
{
/**
* Shared base class for concrete implementations.
*/
@SuppressWarnings("serial")
private abstract static class Base
*public class Info {
* @JsonAlias({ "n", "Name" })
* public String name;
*}
*
*
* @since 2.9
*/
@Target({ElementType.ANNOTATION_TYPE, // for combo-annotations
ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER// for properties (field, setter, ctor param)
})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonAlias
{
/**
* One or more secondary names to accept as aliases to the official name.
*/
public String[] value() default { };
}
JsonAnyGetter.java 0000664 0000000 0000000 00000002620 13231774410 0036035 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 to be an "any getter"; accessor for getting
* a set of key/value pairs, to be serialized as part of containing POJO
* (similar to unwrapping) along with regular property values it has.
* This typically serves as a counterpart
* to "any setter" mutators (see {@link JsonAnySetter}).
* Note that the return type of annotated methods must be
* {@link java.util.Map}).
*
* @JsonAutoDetect(setterVisibility=Visibility.PUBLIC_ONLY)
*
*/
@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;
/*
/**********************************************************
/* Value class used to enclose information, allow for
/* merging of layered configuration settings.
/**********************************************************
*/
/**
* Helper class used to contain information from a single {@link JsonIgnoreProperties}
* annotation, as well as to provide possible overrides from non-annotation sources.
*
* @since 2.9
*/
public static class Value
implements JacksonAnnotationValue
*
*/
protected final static Value DEFAULT = new Value(DEFAULT_FIELD_VISIBILITY,
Visibility.PUBLIC_ONLY, Visibility.PUBLIC_ONLY, Visibility.ANY,
Visibility.PUBLIC_ONLY);
/**
* Empty instance that specifies no overrides, that is, all visibility
* levels set as {@link Visibility#DEFAULT}.
*/
protected final static Value NO_OVERRIDES = new Value(Visibility.DEFAULT,
Visibility.DEFAULT, Visibility.DEFAULT, Visibility.DEFAULT,
Visibility.DEFAULT);
protected final Visibility _fieldVisibility;
protected final Visibility _getterVisibility;
protected final Visibility _isGetterVisibility;
protected final Visibility _setterVisibility;
protected final Visibility _creatorVisibility;
private Value(Visibility fields,
Visibility getters, Visibility isGetters, Visibility setters,
Visibility creators) {
_fieldVisibility = fields;
_getterVisibility = getters;
_isGetterVisibility = isGetters;
_setterVisibility = setters;
_creatorVisibility = creators;
}
public static Value defaultVisibility() {
return DEFAULT;
}
public static Value noOverrides() {
return NO_OVERRIDES;
}
public static Value from(JsonAutoDetect src) {
return construct(src.fieldVisibility(),
src.getterVisibility(), src.isGetterVisibility(), src.setterVisibility(),
src.creatorVisibility());
}
/**
* Factory method for cnstructing instance with visibility of specified accessor
* (or, in case of ALL
, all of them) set as specified; and the
* rest (if any) set as {@link Visibility#DEFAULT}).
*/
public static Value construct(PropertyAccessor acc, Visibility visibility) {
Visibility fields = Visibility.DEFAULT;
Visibility getters = Visibility.DEFAULT;
Visibility isGetters = Visibility.DEFAULT;
Visibility setters = Visibility.DEFAULT;
Visibility creators = Visibility.DEFAULT;
switch (acc) {
case CREATOR:
creators = visibility;
break;
case FIELD:
fields = visibility;
break;
case GETTER:
getters = visibility;
break;
case IS_GETTER:
isGetters = visibility;
break;
case NONE:
break;
case SETTER:
setters = visibility;
break;
case ALL: // default
fields = getters = isGetters = setters = creators = visibility;
break;
}
return construct(fields, getters, isGetters, setters, creators);
}
public static Value construct(Visibility fields,
Visibility getters, Visibility isGetters, Visibility setters,
Visibility creators)
{
Value v = _predefined(fields, getters, isGetters, setters, creators);
if (v == null) {
v = new Value(fields, getters, isGetters, setters, creators);
}
return v;
}
public Value withFieldVisibility(Visibility v) {
return construct(v, _getterVisibility, _isGetterVisibility,
_setterVisibility, _creatorVisibility);
}
public Value withGetterVisibility(Visibility v) {
return construct(_fieldVisibility, v, _isGetterVisibility,
_setterVisibility, _creatorVisibility);
}
public Value withIsGetterVisibility(Visibility v) {
return construct(_fieldVisibility, _getterVisibility, v,
_setterVisibility, _creatorVisibility);
}
public Value withSetterVisibility(Visibility v) {
return construct(_fieldVisibility, _getterVisibility, _isGetterVisibility,
v, _creatorVisibility);
}
public Value withCreatorVisibility(Visibility v) {
return construct(_fieldVisibility, _getterVisibility, _isGetterVisibility,
_setterVisibility, v);
}
public static Value merge(Value base, Value overrides)
{
return (base == null) ? overrides
: base.withOverrides(overrides);
}
public Value withOverrides(Value overrides) {
if ((overrides == null) || (overrides == NO_OVERRIDES) || (overrides == this)) {
return this;
}
if (_equals(this, overrides)) {
return this;
}
Visibility fields = overrides._fieldVisibility;
if (fields == Visibility.DEFAULT) {
fields = _fieldVisibility;
}
Visibility getters = overrides._getterVisibility;
if (getters == Visibility.DEFAULT) {
getters = _getterVisibility;
}
Visibility isGetters = overrides._isGetterVisibility;
if (isGetters == Visibility.DEFAULT) {
isGetters = _isGetterVisibility;
}
Visibility setters = overrides._setterVisibility;
if (setters == Visibility.DEFAULT) {
setters = _setterVisibility;
}
Visibility creators = overrides._creatorVisibility;
if (creators == Visibility.DEFAULT) {
creators = _creatorVisibility;
}
return construct(fields, getters, isGetters, setters, creators);
}
@Override
public Class
*
* Also note that all {@link JsonProperty} annotations must specify actual name
* (NOT empty String for "default") unless you use one of extension modules
* that can detect parameter name; this because default JDK versions before 8
* have not been able to store and/or retrieve parameter names from bytecode.
* But with JDK 8 (or using helper libraries such as Paranamer, or other JVM
* languages like Scala or Kotlin), specifying name is optional.
*java.lang.String
) during deserialization,
* and serialize values using {@link JsonValue}.
*@READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
* deserialization feature is enabled.
* com.fasterxml.jackson.databind.ObjectMapper
(or objects
* it delegates to) providing matching filters by id.
*com.fasterxml.jackson.databind.ser.BeanPropertyFilter
and
* are registered through com.fasterxml.jackson.databind.ObjectMapper
*
*
*
* @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.
*toString()
);
* but it is also possible to use {@link Shape#OBJECT} to serialize (but not deserialize)
* {@link java.lang.Enum}s as JSON Objects (as if they were POJOs). NOTE: serialization
* as JSON Object only works with class annotation;
* will not work as per-property annotation.
* ObjectMapper
.
*/
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
* default (UTC) unless explicitly set to another timezone.
*/
public String timezone() default DEFAULT_TIMEZONE;
/**
* Property that indicates whether "lenient" handling should be enabled or
* disabled. This is relevant mostly for deserialization of some textual
* datatypes, especially date/time types.
*SerializationFeature
* or DeserializationFeature
, as noted by entries.
*JsonSerializer
/ JsonDeserializer
being used
* takes the format setting into account. If not, please file an issue
* for adding support via issue tracker for package that has handlers
* (if you know which one; if not, just use `jackson-databind`).
*
* @since 2.6
*/
public enum Feature {
/**
* Override for DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY
* which will allow deserialization of JSON non-array values into single-element
* Java arrays and {@link java.util.Collection}s.
*/
ACCEPT_SINGLE_VALUE_AS_ARRAY,
/**
* Override for MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES
.
* Only affects deserialization, has no effect on serialization.
*SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS
,
* similar constraints apply.
*/
WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS,
/**
* Override for SerializationFeature.WRITE_DATES_WITH_ZONE_ID
,
* similar constraints apply.
*/
WRITE_DATES_WITH_ZONE_ID,
/**
* Override for SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED
* which will force serialization of single-element arrays and {@link java.util.Collection}s
* as that single element and excluding array wrapper.
*/
WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED,
/**
* Override for SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS
,
* enabling of which will force sorting of {@link java.util.Map} keys before
* serialization.
*/
WRITE_SORTED_MAP_ENTRIES,
/**
* Override for DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIMEZONE
* that specifies whether context provided timezone
* DeserializationContext.getTimeZone()
should be used to adjust Date/Time
* values on deserialization, even if value itself contains timezone informatio
*Joda
and Java 8 date/time
values,
* but not to java.util.Date
or java.util.Calendar
.
*
* @since 2.8
*/
ADJUST_DATES_TO_CONTEXT_TIME_ZONE
}
/**
* Helper class that encapsulates information equivalent to {@link java.lang.Boolean}
* valued {@link java.util.EnumMap}.
*
* @since 2.6
*/
public static class Features
{
private final int _enabled, _disabled;
private final static Features EMPTY = new Features(0, 0);
private Features(int e, int d) {
_enabled = e;
_disabled = d;
}
public static Features empty() {
return EMPTY;
}
public static Features construct(JsonFormat f) {
return construct(f.with(), f.without());
}
public static Features construct(Feature[] enabled, Feature[] disabled)
{
int e = 0;
for (Feature f : enabled) {
e |= (1 << f.ordinal());
}
int d = 0;
for (Feature f : disabled) {
d |= (1 << f.ordinal());
}
return new Features(e, d);
}
public Features withOverrides(Features overrides) {
// Cheap checks first: maybe one is empty?
if (overrides == null) {
return this;
}
int overrideD = overrides._disabled;
int overrideE = overrides._enabled;
if ((overrideD == 0) && (overrideE == 0)) {
return this;
}
if ((_enabled == 0) && (_disabled == 0)) {
return overrides;
}
// If not, calculate combination with overrides
int newE = (_enabled & ~overrideD) | overrideE;
int newD = (_disabled & ~overrideE) | overrideD;
// one more thing; no point in creating new instance if there's no change
if ((newE == _enabled) && (newD == _disabled)) {
return this;
}
return new Features(newE, newD);
}
public Features with(Feature...features) {
int e = _enabled;
for (Feature f : features) {
e |= (1 << f.ordinal());
}
return (e == _enabled) ? this : new Features(e, _disabled);
}
public Features without(Feature...features) {
int d = _disabled;
for (Feature f : features) {
d |= (1 << f.ordinal());
}
return (d == _disabled) ? this : new Features(_enabled, d);
}
public Boolean get(Feature f) {
int mask = (1 << f.ordinal());
if ((_disabled & mask) != 0) {
return Boolean.FALSE;
}
if ((_enabled & mask) != 0) {
return Boolean.TRUE;
}
return null;
}
@Override
public String toString() {
if (this == EMPTY) {
return "EMPTY";
}
return String.format("(enabled=0x%x,disabled=0x%x)", _enabled, _disabled);
}
@Override
public int hashCode() {
return _disabled + _enabled;
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == null) return false;
if (o.getClass() != getClass()) return false;
Features other = (Features) o;
return (other._enabled == _enabled) && (other._disabled == _disabled);
}
}
/**
* Helper class used to contain information from a single {@link JsonFormat}
* annotation.
*/
public static class Value
implements JacksonAnnotationValue@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! As Jackson 2.6, there is a new and improved way to define
* `read-only` and `write-only` properties, using
* {@link JsonProperty#access()} annotation: this is recommended over
* use of separate JsonIgnore
and {@link JsonProperty}
* annotations.
*true
): but argument can be explicitly defined.
* This can be done to override an existing `JsonIgnore` by explicitly
* defining one with 'false' argument: either in a sub-class, or by
* using "mix-in annotations".
*/
@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.java 0000664 0000000 0000000 00000040474 13231774410 0037444 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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.*;
/**
* Annotation that can be used to either suppress serialization of
* properties (during serialization), or ignore processing of
* JSON properties read (during deserialization).
*
* // 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)
*
*
*
*/
public static Value empty() {
return EMPTY;
}
/**
* Helper method that will try to combine values from two {@link Value}
* instances, using one as base settings, and the other as overrides
* to use instead of base values when defined; base values are only
* use if override does not specify a value (matching value is null
* or logically missing).
* Note that one or both of value instances may be `null`, directly;
* if both are `null`, result will also be `null`; otherwise never null.
*/
public static Value merge(Value base, Value overrides)
{
return (base == null) ? overrides
: base.withOverrides(overrides);
}
/**
* @since 2.8
*/
public static Value mergeAll(Value... values)
{
Value result = null;
for (Value curr : values) {
if (curr != null) {
result = (result == null) ? curr : result.withOverrides(curr);
}
}
return result;
}
public static Value forIgnoredProperties(Setthis
* instance; otherwise new {@link Value} with changed inclusion values.
*/
public Value withOverrides(Value overrides) {
if ((overrides == null) || (overrides == EMPTY)) {
return this;
}
// if non merging, we'll actually end up with just the overrides don't we?
// (given there's no "use default" value for anything
if (!overrides._merge) {
return overrides;
}
if (_equals(this, overrides)) {
return this;
}
// Here's where mergeability needs to be checked
Setnull
value: such a value
* would be serialized as JSON null, and not filtered out.
*Map
s with no values, but would include Map
s
* with `null` values. To exclude Map with only `null` value, you would use both
* annotations like so:
*
*public class Bean {
* {@literal @JsonInclude}(value=Include.NON_EMPTY, content=Include.NON_NULL)
* public Map<String,String> entries;
*}
*
* Similarly you could Maps that only contain
* "empty" elements, or "non-default" values (see {@link Include#NON_EMPTY} and
* {@link Include#NON_DEFAULT} for more details).
*HandlerInstantiator
* (of ObjectMapper
), which by default simply calls
* zero-argument constructor of the Filter Class.
*
* @since 2.9
*/
public Class> valueFilter() default Void.class;
/**
* Specifies type of "Filter Object" to use in case
* {@link #content} is {@link JsonInclude.Include#CUSTOM}:
* if so, an instance is created by calling HandlerInstantiator
* (of ObjectMapper
), which by default simply calls
* zero-argument constructor of the Filter Class.
*
* @since 2.9
*/
public Class> contentFilter() default Void.class;
/*
/**********************************************************
/* Value enumerations
/**********************************************************
*/
/**
* Enumeration used with {@link JsonInclude}
* to define which properties
* of Java Beans are to be included in serialization.
*/
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 properties are included unless their value
* is:
*
*
* This option is mostly used to work with "Optional"s (Java 8, Guava).
*
* @since 2.6
*/
NON_ABSENT,
/**
* Value that indicates that only properties with null value,
* or what is considered empty, are not to be included.
* Definition of emptiness is data type specific; see below
* for details on actual handling.
*
*
* so that as baseline, "empty" set includes values that would be
* excluded by both {@link #NON_NULL} and {@link #NON_ABSENT}.
*Null
values.
* Beyond this base, following types have additional empty values:
*
*
* and for other types, null values are excluded but other exclusions (if any).
*isEmpty()
is called;
* length()
is called,
* and return value of 0 indicates empty String
* JsonSerializer
implementation: if method isEmpty()
* is overridden, it will be called to see if non-null values are
* considered empty (null is always considered empty).
*
*
* With 2.7, definition has been tightened back to only containing types explained
* above (null, absent, empty String, empty containers), and now
* extended definition may be specified using {@link #NON_DEFAULT}.
*/
NON_EMPTY,
/**
* Meaning of this setting depends on context: whether annotation is
* specified for POJO type (class), or not. In latter case annotation
* is either used as the global default, or as property override.
*0
for `int`/`java.lang.Integer`
* and `false` for `bool`/`Boolean`)
* equals()
method, except for the case where property
* has `null` value in which case straight null check is used.
*
*
*/
NON_DEFAULT,
/**
* Value that indicates that separate `filter` Object (specified by
* {@link JsonInclude#valueFilter} for value itself, and/or
* {@link JsonInclude#contentFilter} for contents of structured types)
* is to be used for determining inclusion criteria.
* Filter object's equals()
method is called with value
* to serialize; if it returns true
value is excluded
* (that is, filtered out); if false
value is included.
*
* @since 2.9
*/
CUSTOM,
/**
* Pseudo-value used to indicate that the higher-level defaults make
* sense, to avoid overriding inclusion value. For example, if returned
* for a property this would use defaults for the class that contains
* property, if any defined; and if none defined for that, then
* global serialization inclusion details.
*
* @since 2.6
*/
USE_DEFAULTS
;
}
/*
/**********************************************************
/* Value class used to enclose information
/**********************************************************
*/
/**
* Helper class used to contain information from a single {@link JsonInclude}
* annotation.
*
* @since 2.6
*/
public static class Value
implements JacksonAnnotationValuethis
* instance; otherwise new {@link Value} with changed inclusion values.
*/
public Value withOverrides(Value overrides) {
if ((overrides == null) || (overrides == EMPTY)) {
return this;
}
Include vi = overrides._valueInclusion;
Include ci = overrides._contentInclusion;
Class> vf = overrides._valueFilter;
Class> cf = overrides._contentFilter;
boolean viDiff = (vi != _valueInclusion) && (vi != Include.USE_DEFAULTS);
boolean ciDiff = (ci != _contentInclusion) && (ci != Include.USE_DEFAULTS);
boolean filterDiff = (vf != _valueFilter) || (cf != _valueFilter);
if (viDiff) {
if (ciDiff) {
return new Value(vi, ci, vf, cf);
}
return new Value(vi, _contentInclusion, vf, cf);
} else if (ciDiff) {
return new Value(_valueInclusion, ci, vf, cf);
} else if (filterDiff) {
return new Value(_valueInclusion, _contentInclusion, vf, cf);
}
return this;
}
/**
* Factory method to use for constructing an instance for components
*/
public static Value construct(Include valueIncl, Include contentIncl) {
if (((valueIncl == Include.USE_DEFAULTS) || (valueIncl == null))
&& ((contentIncl == Include.USE_DEFAULTS) || (contentIncl == null))) {
return EMPTY;
}
return new Value(valueIncl, contentIncl, null, null);
}
/**
* Factory method to use for constructing an instance for components
*
* @since 2.9
*/
public static Value construct(Include valueIncl, Include contentIncl,
Class> valueFilter, Class> contentFilter)
{
if (valueFilter == Void.class) {
valueFilter = null;
}
if (contentFilter == Void.class) {
contentFilter = null;
}
if (((valueIncl == Include.USE_DEFAULTS) || (valueIncl == null))
&& ((contentIncl == Include.USE_DEFAULTS) || (contentIncl == null))
&& (valueFilter == null)
&& (contentFilter == null)
) {
return EMPTY;
}
return new Value(valueIncl, contentIncl, valueFilter, contentFilter);
}
/**
* Factory method to use for constructing an instance from instance of
* {@link JsonInclude}
*/
public static Value from(JsonInclude src) {
if (src == null) {
return EMPTY;
}
Include vi = src.value();
Include ci = src.content();
if ((vi == Include.USE_DEFAULTS) && (ci == Include.USE_DEFAULTS)) {
return EMPTY;
}
Class> vf = src.valueFilter();
if (vf == Void.class) {
vf = null;
}
Class> cf = src.contentFilter();
if (cf == Void.class) {
cf = null;
}
return new Value(vi, ci, vf, cf);
}
public Value withValueInclusion(Include incl) {
return (incl == _valueInclusion) ? this
: new Value(incl, _contentInclusion, _valueFilter, _contentFilter);
}
/**
* Mutant factory that will either
*
*
*
* @since 2.9
*/
public Value withValueFilter(Class> filter) {
Include incl;
if (filter == null || filter == Void.class) { // clear filter
incl = Include.USE_DEFAULTS;
filter = null;
} else {
incl = Include.CUSTOM;
}
return construct(incl, _contentInclusion, filter, _contentFilter);
}
/**
* Mutant factory that will either
*value
as USE_DEFAULTS
* and valueFilter
to filter
(if filter not null);
* orvalue
as ALWAYS
(if filter null)
*
*
*
* @since 2.9
*/
public Value withContentFilter(Class> filter) {
Include incl;
if (filter == null || filter == Void.class) { // clear filter
incl = Include.USE_DEFAULTS;
filter = null;
} else {
incl = Include.CUSTOM;
}
return construct(_valueInclusion, incl, _valueFilter, filter);
}
public Value withContentInclusion(Include incl) {
return (incl == _contentInclusion) ? this
: new Value(_valueInclusion, incl, _valueFilter, _contentFilter);
}
@Override
public Classcontent
as USE_DEFAULTS
* and contentFilter
to filter
(if filter not null);
* orcontent
as ALWAYS
(if filter null)
* int
has a value,
* but no obvious and non-ambiguous way to merge state.
*JsonDeserializer
implementation
* to use that base state in a way that makes sense without further configuration.
* For structured types this is usually obvious; and for scalar types not -- if
* no obvious method exists, merging is not allowed; deserializer may choose to
* either quietly ignore it, or throw an exception.
*ObjectMapper
* and Object
have "updating reader" operations.
*Enum
like so:
*
public enum MyEnum {
{@literal @JsonProperty}("theFirstValue") THE_FIRST_VALUE,
{@literal @JsonProperty}("another_value") ANOTHER_VALUE;
}
* as an alternative to using {@link JsonValue} annotation.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonProperty
{
/**
* Special value that indicates that handlers should use the default
* name (derived from method or field name) for property.
*
* @since 2.1
*/
public final static String USE_DEFAULT_NAME = "";
/**
* Marker value used to indicate that no index has been specified.
* Used as the default value as annotations do not allow "missing"
* values.
*
* @since 2.4
*/
public final static int INDEX_UNKNOWN = -1;
/**
* Defines name of the logical property, i.e. JSON object field
* name to use for the property. If value is empty String (which is the
* default), will try to use name of the field that is annotated.
* Note that there is
* no default name available for constructor arguments,
* meaning that
* Empty String is not a valid value for constructor arguments.
*/
String value() default USE_DEFAULT_NAME;
/**
* Property that indicates whether a value (which may be explicit
* null) is expected for property during deserialization or not.
* If expected, BeanDeserialized
should indicate
* this as a validity problem (usually by throwing an exception,
* but this may be sent via problem handlers that can try to
* rectify the problem, for example, by supplying a default
* value).
*JsonProperty
combination.
*
* @since 2.6
*/
public enum Access
{
/**
* Access setting which means that visibility rules are to be used
* to automatically determine read- and/or write-access of this property.
*/
AUTO,
/**
* Access setting that means that the property may only be read for serialization,
* but not written (set) during deserialization.
*/
READ_ONLY,
/**
* Access setting that means that the property may only be written (set)
* for deserialization,
* but will not be read (get) on serialization, that is, the value of the property
* is not included in serialization.
*/
WRITE_ONLY,
/**
* Access setting that means that the property will be accessed for both
* serialization (writing out values as external representation)
* and deserialization (reading values from external representation),
* regardless of visibility rules.
*/
READ_WRITE
;
}
}
JsonPropertyDescription.java 0000664 0000000 0000000 00000001546 13231774410 0040171 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation used to define a human readable description for a logical
* property.
* Currently used to populate the description field in generated JSON
* Schemas.
*
* @since 2.3
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Documented // since 2.6
@JacksonAnnotation
public @interface JsonPropertyDescription
{
/**
* Defines a human readable description of the logical property.
* Currently used to populate the description field in generated JSON
* Schemas.
*/
String value() default "";
}
JsonPropertyOrder.java 0000664 0000000 0000000 00000003607 13231774410 0036761 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 define ordering (possibly partial) to use
* when serializing object properties. Properties included in annotation
* declaration will be serialized first (in defined order), followed by
* any properties not included in the definition.
* Annotation definition will override any implicit orderings (such as
* guarantee that Creator-properties are serialized before non-creator
* properties)
*
* // ensure that "id" and "name" are output before other properties
* @JsonPropertyOrder({ "id", "name" })
* // order any properties that don't have explicit setting using alphabetic order
* @JsonPropertyOrder(alphabetic=true)
*
*true
to force
* wrapping of root element, regardless of whether globally
* "root wrapping" is enabled or not.
*false
is taken to mean "use defaults",
* and will not block use of wrapper if use is indicated by global features.
*
* @since 2.4
public boolean alwaysWrap() default false;
*/
}
JsonSetter.java 0000664 0000000 0000000 00000022750 13231774410 0035407 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
import java.lang.annotation.*;
/**
* Annotation that can be used to define a non-static,
* single-argument method to be used as a "setter" for a logical property
* as an alternative to recommended
* {@link JsonProperty} annotation;
* or (as of 2.9 and later), specify additional aspects of the
* assigning property a value during serialization.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
// ^^^ allowed on Fields, (constructor) parameters since 2.9
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonSetter
{
/**
* Optional default argument that defines logical property this
* method is used to modify ("set"); this is the property
* name used in JSON content.
*/
String value() default "";
/**
* Specifies action to take when input contains explicit `null` value
* (if format has one).
* Default action, in absence of any explicit configuration,
* is usually {@link Nulls#SET}, meaning that the `null` is set as
* value using setter.
*
*
*/
public static Value empty() {
return EMPTY;
}
/**
* Helper method that will try to combine values from two {@link Value}
* instances, using one as base settings, and the other as overrides
* to use instead of base values when defined; base values are only
* use if override does not specify a value (matching value is null
* or logically missing).
* Note that one or both of value instances may be `null`, directly;
* if both are `null`, result will also be `null`; otherwise never null.
*/
public static Value merge(Value base, Value overrides)
{
return (base == null) ? overrides
: base.withOverrides(overrides);
}
public static Value forValueNulls(Nulls nulls) {
return construct(nulls, Nulls.DEFAULT);
}
public static Value forValueNulls(Nulls nulls, Nulls contentNulls) {
return construct(nulls, contentNulls);
}
public static Value forContentNulls(Nulls nulls) {
return construct(Nulls.DEFAULT, nulls);
}
/**
* Mutant factory method that merges values of this value with given override
* values, so that any explicitly defined inclusion in overrides has precedence over
* settings of this value instance. If no overrides exist will return this
* instance; otherwise new {@link Value} with changed inclusion values.
*/
public Value withOverrides(Value overrides) {
if ((overrides == null) || (overrides == EMPTY)) {
return this;
}
Nulls nulls = overrides._nulls;
Nulls contentNulls = overrides._contentNulls;
if (nulls == Nulls.DEFAULT) {
nulls = _nulls;
}
if (contentNulls == Nulls.DEFAULT) {
contentNulls = _contentNulls;
}
if ((nulls == _nulls) && (contentNulls == _contentNulls)) {
return this;
}
return construct(nulls, contentNulls);
}
public Value withValueNulls(Nulls nulls) {
if (nulls == null) {
nulls = Nulls.DEFAULT;
}
if (nulls == _nulls) {
return this;
}
return construct(nulls, _contentNulls);
}
public Value withValueNulls(Nulls valueNulls, Nulls contentNulls) {
if (valueNulls == null) {
valueNulls = Nulls.DEFAULT;
}
if (contentNulls == null) {
contentNulls = Nulls.DEFAULT;
}
if ((valueNulls == _nulls) && (contentNulls == _contentNulls)) {
return this;
}
return construct(valueNulls, contentNulls);
}
public Value withContentNulls(Nulls nulls) {
if (nulls == null) {
nulls = Nulls.DEFAULT;
}
if (nulls == _contentNulls) {
return this;
}
return construct(_nulls, nulls);
}
public Nulls getValueNulls() { return _nulls; }
public Nulls getContentNulls() { return _contentNulls; }
/**
* Returns same as {@link #getValueNulls()} unless value would be
* {@link Nulls#DEFAULT} in which case `null` is returned.
*/
public Nulls nonDefaultValueNulls() {
return (_nulls == Nulls.DEFAULT) ? null : _nulls;
}
/**
* Returns same as {@link #getContentNulls()} unless value would be
* {@link Nulls#DEFAULT} in which case `null` is returned.
*/
public Nulls nonDefaultContentNulls() {
return (_contentNulls == Nulls.DEFAULT) ? null : _contentNulls;
}
/*
/**********************************************************
/* Std method overrides
/**********************************************************
*/
@Override
public String toString() {
return String.format("JsonSetter.Value(valueNulls=%s,contentNulls=%s)",
_nulls, _contentNulls);
}
@Override
public int hashCode() {
return _nulls.ordinal() + (_contentNulls.ordinal() << 2);
}
@Override
public boolean equals(Object o) {
if (o == this) return true;
if (o == null) return false;
if (o.getClass() == getClass()) {
Value other = (Value) o;
return (other._nulls == _nulls)
&& (other._contentNulls == _contentNulls);
}
return false;
}
/*
/**********************************************************
/* Internal methods
/**********************************************************
*/
private static boolean _empty(Nulls nulls, Nulls contentNulls) {
return (nulls == Nulls.DEFAULT)
&& (contentNulls == Nulls.DEFAULT);
}
}
}
JsonSubTypes.java 0000664 0000000 0000000 00000003437 13231774410 0035720 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 with {@link JsonTypeInfo} to indicate sub-types of serializable
* polymorphic types, and to associate logical names used within JSON content
* (which is more portable than using physical Java class names).
*
* // Include Java class name ("com.myempl.ImplClass") as JSON property "class"
* @JsonTypeInfo(use=Id.CLASS, include=As.PROPERTY, property="class")
*
* // Include logical type name (defined in impl classes) as wrapper; 2 annotations
* @JsonTypeInfo(use=Id.NAME, include=As.WRAPPER_OBJECT)
* @JsonSubTypes({com.myemp.Impl1.class, com.myempl.Impl2.class})
*
* Alternatively you can also define fully customized type handling by using
* @JsonTypeResolver
annotation (from databind package).
*visible = true
* in which case property will be passed as-is to deserializers
* (and set via setter or field) on deserialization.
*
* NOTE: leading dot ('.') MUST be used to denote partial (minimal) name;
* if it is missing, value is assumed to be fully-qualified name. Fully-qualified
* name is used in cases where subtypes are not in same package (or sub-package
* thereof) as base class.
*java.lang.Object
would not be very
* useful reference point), this may not always work as expected.
*/
MINIMAL_CLASS("@c"),
/**
* Means that logical type name is used as type information; name will then need
* to be separately resolved to actual concrete type (Class).
*/
NAME("@type"),
/**
* Means that typing mechanism uses customized handling, with possibly
* custom configuration. This means that semantics of other properties is
* not defined by Jackson package, but by the custom implementation.
*/
CUSTOM(null)
;
private final String _defaultPropertyName;
private Id(String defProp) {
_defaultPropertyName = defProp;
}
public String getDefaultPropertyName() { return _defaultPropertyName; }
}
/**
* Definition of standard type inclusion mechanisms for type metadata.
* Used for standard metadata types, except for {@link Id#NONE}.
* May or may not be used for custom types ({@link Id#CUSTOM}).
*/
public enum As {
/**
* Inclusion mechanism that uses a single configurable property, included
* along with actual data (POJO properties) as a separate meta-property.
* PROPERTY
, except that
* property is included one-level higher in hierarchy, i.e. as sibling
* property at same level as JSON Object to type.
* Note that this choice can only be used for properties, not
* for types (classes). Trying to use it for classes will result in
* inclusion strategy of basic PROPERTY
instead.
*/
EXTERNAL_PROPERTY,
/**
* Inclusion mechanism similar to PROPERTY
with respect
* to deserialization; but one that is produced by a "regular" accessible
* property during serialization. This means that TypeSerializer
* will do nothing, and expects a property with defined name to be output
* using some other mechanism (like default POJO property serialization, or
* custom serializer).
*TypeSerializer
is basically suppressed;
* whereas with {@link JsonTypeId}, output of regular property is suppressed.
* This mostly matters with respect to output order; this choice is the only
* way to ensure specific placement of type id during serialization.
*
* @since 2.3.0 but databind only since 2.5.0.
*/
EXISTING_PROPERTY
;
}
/*
/**********************************************************
/* Annotation properties
/**********************************************************
*/
/**
* Specifies kind of type metadata to use when serializing
* type information for instances of annotated type
* and its subtypes; as well as what is expected during
* deserialization.
*/
public Id use();
/**
* Specifies mechanism to use for including type metadata (if any; for
* {@link Id#NONE} nothing is included); used when serializing,
* and expected when deserializing.
*String
) is based on
* type metadata type ({@link #use}) used.
*/
public String property() default "";
/**
* Optional property that can be used to specify default implementation
* class to use for deserialization if type identifier is either not present,
* or can not be mapped to a registered type (which can occur for ids,
* but not when specifying explicit class to use).
* Property has no effect on choice of type id used for serialization;
* it is only used in deciding what to do for otherwise unmappable cases.
*
*
*/
public Class> defaultImpl() default JsonTypeInfo.class;
/**
* Property that defines whether type identifier value will be passed
* as part of JSON stream to deserializer (true), or handled and
* removed by com.fasterxml.jackson.databind.annotation.NoClass
is also allowed
* for such usage.
* TypeDeserializer
(false).
* Property has no effect on serialization.
*JsonDeserializer
.
*
* @since 2.0
*/
public boolean visible() default false;
// 19-Dec-2014, tatu: Was hoping to implement for 2.5, but didn't quite make it.
// Hope for better luck with 2.8 or later
/**
* Property that defines whether type serializer is allowed to omit writing
* of type id, in case that value written has type same as {@link #defaultImpl()}.
* If true, omission is allowed (although writer may or may not be able to do that);
* if false, type id should always be written still.
*
* @since 2.5
public boolean skipWritingDefault() default false;
/*
/*
/**********************************************************
/* Helper classes
/**********************************************************
*/
/**
* This marker class that is only to be used with defaultImpl
* annotation property, to indicate that there is no default implementation
* specified.
*
* @deprecated Since 2.5, use any Annotation type (such as {@link JsonTypeInfo},
* if such behavior is needed; this is rarely necessary.
*/
@Deprecated
public abstract static class None { }
}
JsonTypeName.java 0000664 0000000 0000000 00000001453 13231774410 0035660 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 binding logical name that the annotated class
* has. Used with {@link JsonTypeInfo} (and specifically its
* {@link JsonTypeInfo#use} property) to establish relationship
* between type names and types.
*
* @author tatu
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonTypeName {
/**
* Logical type name for annotated type. If missing (or defined as Empty String),
* defaults to using non-qualified class name as the type.
*/
public String value() default "";
}
JsonUnwrapped.java 0000664 0000000 0000000 00000005073 13231774410 0036105 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 a property should be serialized
* "unwrapped"; that is, if it would be serialized as JSON Object, its
* properties are instead included as properties of its containing
* Object. For example, consider case of POJO like:
*
*
* public class Parent {
* public int age;
* public Name name;
* }
* public class Name {
* public String first, last;
* }
*
* which would normally be serialized as follows (assuming @JsonUnwrapped
* had no effect):
*
* {
* "age" : 18,
* "name" : {
* "first" : "Joey",
* "last" : "Sixpack"
* }
* }
*
* can be changed to this:
*
* {
* "age" : 18,
* "first" : "Joey",
* "last" : "Sixpack"
* }
*
* by changing Parent class to:
*
* public class Parent {
* public int age;
* @JsonUnwrapped
* public Name name;
* }
*
* Annotation can only be added to properties, and not classes, as it is contextual.
*
*
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonUnwrapped
{
/**
* Property that is usually only used when overriding (masking) annotations,
* using mix-in annotations. Otherwise default value of 'true' is fine, and
* value need not be explicitly included.
*/
boolean enabled() default true;
/**
* Optional property that can be used to add prefix String to use in front
* of names of properties that are unwrapped: this can be done for example to prevent
* name collisions.
*/
String prefix() default "";
/**
* Optional property that can be used to add suffix String to append at the end
* of names of properties that are unwrapped: this can be done for example to prevent
* name collisions.
*/
String suffix() default "";
}
JsonValue.java 0000664 0000000 0000000 00000004724 13231774410 0035216 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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 value of annotated accessor (either field
* or "getter" method [a method with non-void return type, no args])
* is to be used as the single value to serialize for the instance,
* instead of the usual method of collecting properties of value.
* Usually value will be of a simple scalar type
* (String or Number), but it can be any serializable type (Collection,
* Map or Bean).
*BeanSerializer
, not a custom serializer
* Class
can be annotated with this annotation;
* if more than one is found, an exception may be thrown.
* Also, if method signature of annotated method is not compatible with Getters,
* an exception may be thrown (whether exception is thrown or not is an
* implementation detail (due to filtering during introspection, some annotations
* may be skipped) and applications should not rely on specific behavior).
*toString()
* method so that returned String value is used as the JSON serialization;
* and if deserialization is needed, there is matching constructor
* or factory method annotated with {@link JsonCreator} annotation.
*enum
s, one additional feature is
* that value returned by annotated method is also considered to be the
* value to deserialize from, not just JSON String to serialize as.
* This is possible since set of Enum values is constant and it is possible
* to define mapping, but can not be done in general for POJO types; as such,
* this is not used for POJO deserialization.
*
* @see JsonCreator
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD,
ElementType.FIELD // since 2.9
})
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
public @interface JsonValue
{
/**
* Optional argument that defines whether this annotation is active
* or not. The only use for value 'false' if for overriding purposes.
* Overriding may be necessary when used
* 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;
}
JsonView.java 0000664 0000000 0000000 00000002764 13231774410 0035056 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package 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;
/**
* Annotation used for indicating view(s) that the property
* that is defined by method or field annotated is part of.
*
* @JsonView(BasicView.class)
*
* which would specify that property annotated would be included
* when processing (serializing, deserializing) View identified
* by BasicView.class
(or its sub-class).
* If multiple View class identifiers are included, property will
* be part of all of them.
*getNullValue(...)
* method)
*/
SET,
/**
* Value that indicates that an input null value should be skipped and
* no assignment is to be made; this usually means that the property
* will have its default value.
*/
SKIP,
/**
* Value that indicates that an exception (of type that indicates input mismatch
* problem) is to be thrown, to indicate that null values are not accepted.
*/
FAIL,
/**
* Value that indicates that value to assign should come from the value
* deserializer of the type, using method getEmptyValue()
.
*/
AS_EMPTY,
/**
* Pseudo-value used to indicate that defaults are to be used for handling,
* that is, this value specifies no explicit handling override.
*/
DEFAULT
;
} ObjectIdGenerator.java 0000664 0000000 0000000 00000014112 13231774410 0036632 0 ustar 00root root 0000000 0000000 jackson-annotations-jackson-annotations-2.9.4/src/main/java/com/fasterxml/jackson/annotation package com.fasterxml.jackson.annotation;
/**
* Definition of API used for constructing Object Identifiers
* (as annotated using {@link JsonIdentityInfo}).
* Also defines factory methods used for creating instances
* for serialization, deserialization.
*
* @param true
* if the Object Id may be serialized as JSON Object; used by, for example,
* JSOG handling.
* The reason accessor is needed is because handling such Object Ids is
* more complex and may incur additional buffering or performance overhead,
* avoiding of which makes sense for common case of scalar object ids
* (or native object ids some formats support).
*false
, so needs to be overridden
* by Object-producing generators.
*
* @since 2.5
*/
public boolean maySerializeAsObject() {
return false;
}
/**
* Accessor that may be called (after verifying (via {@link #maySerializeAsObject()})
* whether given name
*
* @param name Name of property to check
* @param parser Parser that points to property name, in case generator needs
* further verification (note: untyped, because JsonParser
is defined
* in `jackson-core`, and this package does not depend on it).
*
* @since 2.5
*/
public boolean isValidReferencePropertyName(String name, Object parser) {
return false;
}
/*
/**********************************************************
/* Factory methods
/**********************************************************
*/
/**
* Factory method to create a blueprint instance for specified
* scope. Generators that do not use scope may return 'this'.
*/
public abstract ObjectIdGeneratorcom.fasterxml.jackson.databind.SerializerProvider
,
* but can not be declared here as type itself (as well as call
* to this object) comes from databind package.
*
* @param context Serialization context object used (of type
* com.fasterxml.jackson.databind.SerializerProvider
;
* may be needed by more complex generators to access contextual
* information such as configuration.
*/
public abstract ObjectIdGenerator
*
*