Skip to content

Commit c04af7f

Browse files
committed
Implement #58
1 parent a550262 commit c04af7f

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

release-notes/VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ NOTE: Annotations module will never contain changes in patch versions,
1414
2.6.0 (not yet released)
1515

1616
#56: Improve `ObjectIdGenerators.key()` to handle `null` appropriately by returning `null`
17+
#58: Add new properties for `@JsonIgnoreProperties`, "allowGetters", "allowSetters"
1718

1819
2.5.0 (01-Jan-2015)
1920

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
* of property to bind to
2424
* </li>
2525
* </ul>
26-
* Also note that all {@link JsonProperty} annotations MUST use actual name
27-
* (NOT empty String for "default"): this because Java bytecode does not
28-
* retain names of method or constructor arguments.
29-
*<br />
30-
* NOTE: as of JDK 8, some of above changes, with introduction of names for
31-
* constructor and method parameters.
32-
*
26+
* Also note that all {@link JsonProperty} annotations must specify actual name
27+
* (NOT empty String for "default") unless you use one of extension modules
28+
* that can detect parameter name; this because default JDK versions before 8
29+
* have not been able to store and/or retrieve parameter names from bytecode.
30+
* But with JDK 8 (or using helper libraries such as Paranamer, or other JVM
31+
* languages like Scala or Kotlin), specifying name is optional.
32+
*<p>
33+
* NOTE: As of Jackson 2.6, use of {@link JsonProperty#required()} is supported
34+
* for Creator methods (but not necessarily for regular setters or fields!).
3335
*/
3436
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR})
3537
@Retention(RetentionPolicy.RUNTIME)

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,30 @@
4848
* Does not have any effect on serialization.
4949
*/
5050
public boolean ignoreUnknown() default false;
51+
52+
/**
53+
* Property that can be enabled to allow "getters" to be used (that is,
54+
* prevent ignoral of getters for properties listed in {@link #value()}).
55+
* This is commonly set to support defining "read-only" properties; ones
56+
* for which there is a getter, but no matching setter: in this case,
57+
* properties should be ignored for deserialization but NOT serialization.
58+
* Default value is `false`, which means that getters with matching names
59+
* will be ignored.
60+
*
61+
* @since 2.6
62+
*/
63+
public boolean allowGetters() default false;
64+
65+
/**
66+
* Property that can be enabled to allow "setters" to be used (that is,
67+
* prevent ignoral of setters for properties listed in {@link #value()}).
68+
* This could be used to specify "write-only" properties; ones
69+
* that should not be serialized out, but that may be provided in for
70+
* deserialization.
71+
* Default value is `false`, which means that setters with matching names
72+
* will be ignored.
73+
*
74+
* @since 2.6
75+
*/
76+
public boolean allowSetters() default false;
5177
}

0 commit comments

Comments
 (0)