Similar to this question I want to ignore a field in my java POJO. However, I want to always ignore the field whether or not it is null. 
In my case I need to populate the field value for logic but later when I am outputting my xml I do not want this field included.
@AllArgsConstructor
@NoArgsConstructor
public class MyNotification {
    @Setter @Getter private String id;
    @Setter @Getter private String time;
    @Setter @Getter private String flag;
    @Setter @Getter private String event;
    @Setter @Getter private String type;
}
The output should look like this:
    <MyNotification>
        <id>112314</id>
        <time>2019-08-20T08:41:45Z</time>
        <flag>new</flag>
        <type>T01</type>
    </MyNotification>
Have experimented with @JsonIgnore but when used the field does not get populated.
 
    