JAXB unmarshal excludes a specific element

I know for annotation @XmlTransient , but sometimes I need this element, and in other cases of use I really have to prevent it from unmarshaling, because it contains base64 text. Therefore, I need to exclude it due to performance issues.

Is there a way to dynamically exclude one element from unmarshaling with JAXB?

+3
source share
1 answer

Maybe a nontrivial setter will be enough for you? JAXB will call the setter, and inside you will do something like this:

 public void setMyProperty(String myProperty) {
    if (someSpecialBusinessDecision()) { 
        this.myProperty = myProperty;
    }
 }
0
source

Source: https://habr.com/ru/post/1736500/


All Articles