Pergunta

I have an object I'm serializing with annotations:

@Component
@XmlRootElement(name="Stats")
@XmlAccessorType(XmlAccessType.FIELD)
public class Statistique
{
    @XmlElement(name="TotalUsers")
    private int nbUserTotal;

    @XmlElementWrapper(name="UtilisateursParAppli")
    @XmlElement(name="Application")
    private List<Application> nbUserByAppli;

    @XmlElementWrapper(name="SignaturePolicies")
    @XmlElement(name="SignaturePolicy")
    private List<String> signaturePolicies;

    @XmlElementWrapper(name="ValidationPolicies")
    @XmlElement(name="ValidationPolicy")
    private List<String> validationPolicies;

    ....
}

I want to add an attribute "count" on SignaturePolicies and ValidationPolicies node. Is it possible to achieve that with XML Annotations?

Foi útil?

Solução

Instead of using @XmlElementWrapper you will need to create two classes: SignaturePolicies and ValidationPolicies and work them into your domain model. Each of these will have the count property you wish to add and their corresponding collection (which they replaced on the Statistique class.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top