开发者

JAXB runtime specify what to marshall

开发者 https://www.devze.com 2023-03-20 19:52 出处:网络
Im wondering is there any RUNTIME possibility how to select which fields should be omitted during marshalling. I know that there is @XmlTransient annotation, but that is not runtime.

Im wondering is there any RUNTIME possibility how to select which fields should be omitted during marshalling. I know that there is @XmlTransient annotation, but that is not runtime.

E.g.

@XmlRootElement
public class Person {

  @XmlElement
  private String name;
  @XmlElement
  private int age;

}

w开发者_运维知识库anting both of those ouputs, but the decision is made runtime:

<person>
  <name>foo</name>
  <age>boo</age>
</person>

<person>
  <name>foo</name>
</person>
0

精彩评论

暂无评论...
验证码 换一张
取 消