Skip to content

Jaxb names customization #462

Closed Answered by CarstenWickner
theseeker58 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @theseeker58,

You correctly referred to Jackson's @JsonProperty annotations already being supported, which tells you it can be configured. 😃
That's what "Property Name Overrides" are for (as I call them). They are mentioned in the documentation.

The example given there only needs a tiny adjustment to also apply for @XmlElement annotations:

configBuilder.forFields()
    .withPropertyNameOverrideResolver(field -> Optional
            .ofNullable(field.getAnnotationConsideringFieldAndGetter(XmlElement.class))
            .map(XmlElement::name).orElse(null));

That should do it.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by theseeker58
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants