Reputation: 3893
What happened if there is no value for some class fields in xml file during JAXB unmarshalling? JAXB just "omit" this value and left them uninitialized?
Upvotes: 1
Views: 537
Reputation: 4180
they will get initialized.
Initial values for fields will be set and the no-arg constructor will also run.
for example:
class AClass {
private int x = 5;
private int y = 16;
private Object object;
public AClass() {
this.x = 100;
}
// getters and setters
// ...
}
if the values in the xml for x, y, z and object are omitted there valus will be:
x: 100 (the constructor runs after the field value initialization) y: 16 (from the field value initialization) object: null (objects get initialized to null if no value is given)
Upvotes: 2