Skip to content

Commit 0d8fb31

Browse files
committed
Add slightly more configurability for JaxbAnnotationModule/annotation-introspector pairing
1 parent 8c45d75 commit 0d8fb31

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

jaxb/src/main/java/com/fasterxml/jackson/module/jaxb/JaxbAnnotationModule.java

+28
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public enum Priority {
5656
*/
5757
protected JsonInclude.Include _nonNillableInclusion;
5858

59+
/**
60+
* Value to pass to
61+
* {@link JaxbAnnotationIntrospector#setNameUsedForXmlValue}
62+
* if defined and non-null.
63+
*
64+
* @since 2.12
65+
*/
66+
protected String _nameUsedForXmlValue;
67+
5968
/*
6069
/**********************************************************
6170
/* Life cycle
@@ -90,6 +99,9 @@ public void setupModule(SetupContext context)
9099
if (_nonNillableInclusion != null) {
91100
intr.setNonNillableInclusion(_nonNillableInclusion);
92101
}
102+
if (_nameUsedForXmlValue != null) {
103+
intr.setNameUsedForXmlValue(_nameUsedForXmlValue);
104+
}
93105
}
94106
switch (_priority) {
95107
case PRIMARY:
@@ -128,6 +140,7 @@ public JaxbAnnotationModule setPriority(Priority p) {
128140
public JaxbAnnotationModule setNonNillableInclusion(JsonInclude.Include incl) {
129141
_nonNillableInclusion = incl;
130142
if (_introspector != null) {
143+
// 13-Nov-2020, tatu: should we pass null "incl"?
131144
_introspector.setNonNillableInclusion(incl);
132145
}
133146
return this;
@@ -139,4 +152,19 @@ public JaxbAnnotationModule setNonNillableInclusion(JsonInclude.Include incl) {
139152
public JsonInclude.Include getNonNillableInclusion() {
140153
return _nonNillableInclusion;
141154
}
155+
156+
/**
157+
* @since 2.12
158+
*/
159+
public JaxbAnnotationModule setNameUsedForXmlValue(String name) {
160+
_nameUsedForXmlValue = name;
161+
if ((name != null) && (_introspector != null)) {
162+
_introspector.setNameUsedForXmlValue(name);
163+
}
164+
return this;
165+
}
166+
167+
public String getNameUsedForXmlValue() {
168+
return _nameUsedForXmlValue;
169+
}
142170
}

0 commit comments

Comments
 (0)