I have a JAXB annotated class say
@XmlRootElement(namespace = "http://www.abc.com/customer")
Class Customer{
@XmlElement(namespace = "http://www.abc.com/customer")
private String Name;
@XmlElement(namespace = "http://www.abc.com/customer")
private String Address;
@XmlTransient
private HashSet set = new HashSet();
public String getName(){
return Name;
}
public void setName(String name){
this.Name = name;
set.add("Name");
}
public String getAddress(){
return Address;
}
public void setAddress(String address){
this.Address = address;
set.add("Address");
}
public void getSet(){
return set;
}
I have a XML of the form
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.abc.com/customer" >
<Name>Ralph</Name>
<Address>Newton Street</Address>
</Customer>
I use JAXB unmarshalling to get the object representation of the XML input. The values for Name and Address are set correctly. However the value of set gets lost(since it is @XMLTransient it gets ignored)
Is there any way of ensuring that it is still set in the object which has been unmarshalled? Some other annotation which I can use?