Skip to content

Commit 85f5f0c

Browse files
committed
fix #60, Add Nullean value type.
1 parent 4595936 commit 85f5f0c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

release-notes/VERSION

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ 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
19+
and usage of default values, not just explicit true/false.
1820
- Add `JsonInclude.Include.NON_ABSENT` value, for excluding "absent" Optional values.
1921

2022
2.5.0 (01-Jan-2015)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.fasterxml.jackson.annotation;
2+
3+
/**
4+
* Nullable Boolean value, "nullean". Needed just because Java annotations
5+
* can not take 'null' as a value (even as default), so there is no
6+
* way to distinguish between explicit `true` and `false`, and lack of
7+
* choice (related: annotations are limited to primitives, so
8+
* {@link java.lang.Boolean} not allowed as solution).
9+
*<p>
10+
* Note: although use of `true` and `false` would be more convenient, they
11+
* can not be chosen since they are Java keyword and compiler won't allow
12+
* the choice. And since enum naming convention suggests all-upper-case,
13+
* that is what is done here.
14+
*
15+
* @since 2.6
16+
*/
17+
public enum Nullean
18+
{
19+
/**
20+
* Value that indicates that the annotation property is explicitly defined to
21+
* be enabled, or true.
22+
*/
23+
TRUE,
24+
25+
/**
26+
* Value that indicates that the annotation property is explicitly defined to
27+
* be disabled, or false.
28+
*/
29+
FALSE,
30+
31+
/**
32+
* Value that indicates that the annotation property does NOT have an explicit
33+
* definition of enabled/disabled (or true/false); instead, a higher-level
34+
* configuration value is used; or lacking higher-level global setting,
35+
* default.
36+
*/
37+
DEFAULT;
38+
}

0 commit comments

Comments
 (0)