Skip to content

Commit

Permalink
Minor change to #60: use name OptBoolean instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 2, 2015
1 parent 9fb1c59 commit b8b740d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion release-notes/VERSION
Expand Up @@ -15,7 +15,7 @@ NOTE: Annotations module will never contain changes in patch versions,

#56: Improve `ObjectIdGenerators.key()` to handle `null` appropriately by returning `null`
#58: Add new properties for `@JsonIgnoreProperties`, "allowGetters", "allowSetters"
#60: Add new value type, `Nullean`, for "nullable booleans", to support proper handling
#60: Add new value type, `OptBoolean`, for "optional booleans", to support proper handling
and usage of default values, not just explicit true/false.
- Add `JsonInclude.Include.NON_ABSENT` value, for excluding "absent" Optional values.

Expand Down
Expand Up @@ -55,6 +55,9 @@
* 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.
*<p>
* Default value is `false`, which means that getters with matching names
* will be ignored.
*
Expand All @@ -68,6 +71,9 @@
* 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.
*<p>
* Default value is `false`, which means that setters with matching names
* will be ignored.
*
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java
Expand Up @@ -90,8 +90,71 @@
* 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.
*<p>
* 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.
*<p>
* 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).
*<p>
* 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.
*
* @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
;
}
}
@@ -1,7 +1,7 @@
package com.fasterxml.jackson.annotation;

/**
* Nullable Boolean value, "nullean". Needed just because Java annotations
* Optional Boolean value ("nullean"). Needed just because Java annotations
* can not take 'null' as a value (even as default), so there is no
* way to distinguish between explicit `true` and `false`, and lack of
* choice (related: annotations are limited to primitives, so
Expand All @@ -14,7 +14,7 @@
*
* @since 2.6
*/
public enum Nullean
public enum OptBoolean
{
/**
* Value that indicates that the annotation property is explicitly defined to
Expand Down

0 comments on commit b8b740d

Please sign in to comment.