I have the below JAXB generated class and I need to create this class
and populate the data for the *id* and *name* element. Any ideas on
how to do that with the below generated class? I don't see any
getters/setters.
**JAXB Generated Class:**
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sampleType", propOrder = {
"idAndNames"
})
public class SampleType
implements ToString
{
@XmlElementRefs({
@XmlElementRef(name = "name", type =
JAXBElement.class),
@XmlElementRef(name = "id", type = JAXBElement.class),
})
protected List<JAXBElement<?>> idAndNames;
public List<JAXBElement<?>> getIdAndNames() {
if (idAndNames == null) {
idAndNames = new ArrayList<JAXBElement<?>>();
}
return this.idAndNames;
}
public String toString() {
final ToStringStrategy strategy =
JAXBToStringStrategy.INSTANCE;
final StringBuilder buffer = new StringBuilder();
append(null, buffer, strategy);
return buffer.toString();
}
public StringBuilder append(ObjectLocator locator,
StringBuilder buffer, ToStringStrategy strategy) {
strategy.appendStart(locator, this, buffer);
appendFields(locator, buffer, strategy);
strategy.appendEnd(locator, this, buffer);
return buffer;
}
public StringBuilder appendFields(ObjectLocator locator,
StringBuilder buffer, ToStringStrategy strategy) {
{
List<JAXBElement<?>> theIdAndNames;
theIdAndNames = (((this.idAndNames!=
null)&&(!this.idAndNames.isEmpty()))?this.getIdAndNames():null);
strategy.appendField(locator, this, "idAndNames",
buffer, theIdAndNames);
}
return buffer;
}
}