Anotaciones JAXB para enumeraciones
Frecuentes
Visto 337 veces
1
I have the following enum definition:
public enum MyEnumeration{
ENUM_ONE("1","foo"),
ENUM_TWO("2","bar");
private String code;
private String description;
public String getDescription()
{
return this.description;
}
public String getCode()
{
return this.code;
}
}
And I want to annotate it with Jaxb annotations so it will be marshalled into the following xml.
<myenumeration>
<code>...</code>
<description>...</description>
</myenumeration>
I've tried several approaches, but wasn't succesful. Any ideas? Thanks in advance!
1 Respuestas
2
Podrías escribir un XmlAdapter
that converts the enum into a domain object with those properties. For examples of using XmlAdapter
ver:
Respondido 28 ago 12, 14:08
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas xml enums annotations jaxb or haz tu propia pregunta.
Thanks for your answer, but your link shows me several blogposts. Which would you suggest to review? Or else how would I start doing this? - bjarne77
@Bjarne77 - This would be a good one to use: blog.bdoughan.com/2010/12/jaxb-and-immutable-objects.html - bdoughan