Skip to content

Commit b8b740d

Browse files
committed
Minor change to #60: use name OptBoolean instead.
1 parent 9fb1c59 commit b8b740d

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

release-notes/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ NOTE: Annotations module will never contain changes in patch versions,
1515

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

src/main/java/com/fasterxml/jackson/annotation/JsonIgnoreProperties.java

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
* This is commonly set to support defining "read-only" properties; ones
5656
* for which there is a getter, but no matching setter: in this case,
5757
* properties should be ignored for deserialization but NOT serialization.
58+
* Another way to think about this setting is that setting it to `true`
59+
* will "disable" ignoring of getters.
60+
*<p>
5861
* Default value is `false`, which means that getters with matching names
5962
* will be ignored.
6063
*
@@ -68,6 +71,9 @@
6871
* This could be used to specify "write-only" properties; ones
6972
* that should not be serialized out, but that may be provided in for
7073
* deserialization.
74+
* Another way to think about this setting is that setting it to `true`
75+
* will "disable" ignoring of setters.
76+
*<p>
7177
* Default value is `false`, which means that setters with matching names
7278
* will be ignored.
7379
*

src/main/java/com/fasterxml/jackson/annotation/JsonProperty.java

+63
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,71 @@
9090
* It may also be used by Jackson extension modules; core jackson databind
9191
* does not have any automated handling beyond simply exposing this
9292
* value through bean property introspection.
93+
*<p>
94+
* It is possible that in future this annotation could be used for value
95+
* defaulting, and especially for default values of Creator properties,
96+
* since they support {@link #required()} in 2.6 and above.
9397
*
9498
* @since 2.5
9599
*/
96100
String defaultValue() default "";
101+
102+
/**
103+
* Optional property that may be used to change the way visibility of
104+
* accessors (getter, field-as-getter) and mutators (contructor parameter,
105+
* setter, field-as-setter) is determined, either so that otherwise
106+
* non-visible accessors (like private getters) may be used; or that
107+
* otherwise visible accessors are ignored.
108+
*<p>
109+
* Default value os {@link Access#AUTO} which means that access is determined
110+
* solely based on visibility and other annotations.
111+
*
112+
* @since 2.6
113+
*/
114+
Access access() default Access.AUTO;
115+
116+
/**
117+
* Various options for {@link #access} property, specifying how property
118+
* may be accessed during serialization ("read") and deserialization ("write")
119+
* (note that the direction of read and write is from perspective of the property,
120+
* not from external data format: this may be confusing in some contexts).
121+
*<p>
122+
* Note that while this annotation modifies access to annotated property,
123+
* its effects may be further overridden by {@link JsonIgnore} property:
124+
* if both annotations are present on an accessors, {@link JsonIgnore}
125+
* has precedence over this property.
126+
*
127+
* @since 2.6
128+
*/
129+
public enum Access
130+
{
131+
/**
132+
* Access setting which means that visibility rules are to be used
133+
* to automatically determine read- and/or write-access of this property.
134+
*/
135+
AUTO,
136+
137+
/**
138+
* Access setting that means that the property may only be read for serialization,
139+
* but not written (set) during deserialization.
140+
*/
141+
READ_ONLY,
142+
143+
/**
144+
* Access setting that means that the property may only be written (set)
145+
* for deserialization,
146+
* but will not be read (get) on serialization, that is, the value of the property
147+
* is not included in serialization.
148+
*/
149+
WRITE_ONLY,
150+
151+
/**
152+
* Access setting that means that the property will be accessed for both
153+
* serialization (writing out values as external representation)
154+
* and deserialization (reading values from external representation),
155+
* regardless of visibility rules.
156+
*/
157+
READ_WRITE
158+
;
159+
}
97160
}

src/main/java/com/fasterxml/jackson/annotation/Nullean.java renamed to src/main/java/com/fasterxml/jackson/annotation/OptBoolean.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.fasterxml.jackson.annotation;
22

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

0 commit comments

Comments
 (0)