Top Description Inners Methods
com.fasterxml.jackson.annotation

public @Interface JsonSetter

extends Annotation
Annotations
@Target:ANNOTATION_TYPE, FIELD, METHOD, PARAMETER
@Retention:RUNTIME
@JacksonAnnotation
Imports
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 JsonProperty annotation; or (as of 2.9 and later), specify additional aspects of the assigning property a value during serialization.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JsonSetter.Value

Helper class used to contain information from a single JsonSetter annotation, as well as to provide possible overrides from non-annotation sources.

Method Summary

Modifier and TypeMethod and Description
public Nulls
contentNulls()

Specifies action to take when input to match into content value (of a java.util.Collection, java.util.Map, array, or referential value) contains explicit `null` value (if format has one) to bind.

public Nulls
nulls()

Specifies action to take when input contains explicit `null` value (if format has one).

public String
value()

Optional default argument that defines logical property this method is used to modify ("set"); this is the property name used in JSON content.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

contentNullsback to summary
public Nulls contentNulls()

Specifies action to take when input to match into content value (of a java.util.Collection, 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 Nulls#SET, meaning that the `null` is included as usual.

nullsback to summary
public Nulls nulls()

Specifies action to take when input contains explicit `null` value (if format has one). Default action, in absence of any explicit configuration, is usually Nulls#SET, meaning that the `null` is set as value using setter.

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.

valueback to summary
public String value()

Optional default argument that defines logical property this method is used to modify ("set"); this is the property name used in JSON content.

com.fasterxml.jackson.annotation back to summary

public Class JsonSetter.Value

extends Object
implements JacksonAnnotationValue<JsonSetter>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, com.fasterxml.jackson.annotation.JacksonAnnotationValue

Helper class used to contain information from a single JsonSetter annotation, as well as to provide possible overrides from non-annotation sources.
Since
2.9

Field Summary

Modifier and TypeField and Description
private final Nulls
private final Nulls
protected static final JsonSetter.Value
EMPTY

Default instance used in place of "default settings".

private static final long

Constructor Summary

AccessConstructor and Description
protected
Value(Nulls nulls, Nulls contentNulls)

Method Summary

Modifier and TypeMethod and Description
private static boolean
_empty(Nulls nulls, Nulls contentNulls)

public static JsonSetter.Value
construct(Nulls nulls, Nulls contentNulls)

Factory method that may be used (although is NOT the recommended way) to construct an instance from a full set of properties.

public static JsonSetter.Value
empty()

Accessor for default instances which has "empty" settings; that is:

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static JsonSetter.Value
public static JsonSetter.Value
public static JsonSetter.Value
forValueNulls(Nulls nulls, Nulls contentNulls)

public static JsonSetter.Value
public Nulls
public Nulls
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public static JsonSetter.Value
merge(JsonSetter.Value base, JsonSetter.Value overrides)

Helper method that will try to combine values from two 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).

public Nulls
nonDefaultContentNulls()

Returns same as getContentNulls() unless value would be Nulls#DEFAULT in which case `null` is returned.

public Nulls
nonDefaultValueNulls()

Returns same as getValueNulls() unless value would be Nulls#DEFAULT in which case `null` is returned.

protected Object
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public Class<JsonSetter>
valueFor()

Implements com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Introspection method that may be used to find actual annotation that may be used as the source for value instance.

public JsonSetter.Value
public JsonSetter.Value
withOverrides(JsonSetter.Value overrides)

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.

public JsonSetter.Value
public JsonSetter.Value
withValueNulls(Nulls valueNulls, Nulls contentNulls)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_contentNullsback to summary
private final Nulls _contentNulls
_nullsback to summary
private final Nulls _nulls
EMPTYback to summary
protected static final JsonSetter.Value EMPTY

Default instance used in place of "default settings".

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

Valueback to summary
protected Value(Nulls nulls, Nulls contentNulls)

Method Detail

_emptyback to summary
private static boolean _empty(Nulls nulls, Nulls contentNulls)
constructback to summary
public static JsonSetter.Value construct(Nulls nulls, Nulls contentNulls)

Factory method that may be used (although is NOT the recommended way) to construct an instance from a full set of properties. Most users would be better off starting by empty() instance and using `withXxx`/`withoutXxx` methods, as this factory method may need to be changed if new properties are added in JsonIgnoreProperties annotation.

emptyback to summary
public static JsonSetter.Value empty()

Accessor for default instances which has "empty" settings; that is:

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
forContentNullsback to summary
public static JsonSetter.Value forContentNulls(Nulls nulls)
forValueNullsback to summary
public static JsonSetter.Value forValueNulls(Nulls nulls)
forValueNullsback to summary
public static JsonSetter.Value forValueNulls(Nulls nulls, Nulls contentNulls)
fromback to summary
public static JsonSetter.Value from(JsonSetter src)
getContentNullsback to summary
public Nulls getContentNulls()
getValueNullsback to summary
public Nulls getValueNulls()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
mergeback to summary
public static JsonSetter.Value merge(JsonSetter.Value base, JsonSetter.Value overrides)

Helper method that will try to combine values from two 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.

nonDefaultContentNullsback to summary
public Nulls nonDefaultContentNulls()

Returns same as getContentNulls() unless value would be Nulls#DEFAULT in which case `null` is returned.

nonDefaultValueNullsback to summary
public Nulls nonDefaultValueNulls()

Returns same as getValueNulls() unless value would be Nulls#DEFAULT in which case `null` is returned.

readResolveback to summary
protected Object readResolve()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
valueForback to summary
public Class<JsonSetter> valueFor()

Implements com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Doc from com.fasterxml.jackson.annotation.JacksonAnnotationValue.valueFor.

Introspection method that may be used to find actual annotation that may be used as the source for value instance.

Returns:Class<JsonSetter>

Annotation class for which instances of this value class are created

Annotations
@Override
withContentNullsback to summary
public JsonSetter.Value withContentNulls(Nulls nulls)
withOverridesback to summary
public JsonSetter.Value withOverrides(JsonSetter.Value overrides)

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 Value with changed inclusion values.

withValueNullsback to summary
public JsonSetter.Value withValueNulls(Nulls nulls)
withValueNullsback to summary
public JsonSetter.Value withValueNulls(Nulls valueNulls, Nulls contentNulls)