Affects Version/s: 2.2.1
Fix Version/s: None
Registering an XmlAdapter<String, Boolean> with the Unmarshaller and marking the bean field with an @XmlJavaTypeAdapter annotation results in the error message:
...is not applicable to the field type boolean.
Here's someone else with a similar request:
My use case is that although I'm happy for marshalling to convert a boolean to the string "true" or "false" for output in XML, I'd like more flexibility in the unmarshalling. Ideally "true" and "TRUE" would unmarshal successfully to boolean = true.
I'm using Jaxb for a simple unmarshalling task of XML to a bean and am not providing a schema or a binding customisation file. For the record, even for the big-B Boolean case it would be great to be able to register default behaviour for booleans without having to tag the bean field with @XmlJavaTypeAdapter. There seems to be no facility to programatically override this default behaviour at the Unmarshaller level.
I could choose to transform the TRUE into a true as part of a preprocessing step. However, I only want to apply that preprocessing logic when the value is definitely going to be attached to a boolean or Boolean. Because I don't have a schema, any preprocessor would have to change all instances of "TRUE", even if they are destined to be a String and would be far better staying as "TRUE".