1

I am comparing the unmarshalling of

private Long longVar
private boolean isLongSetterCalled;

private BigDecimal bigDecVar
private boolean isBigDecimalSetterCalled;

@XmlElement(nillable = true)
public Long getLongVar() {
  return this.longVar;
}
public void setLongVar(final Long longVar) {
  this.longVar = longVar;
  this.longSetterCalled = true;
}

@XmlElement(nillable = true)
public BigDecimal getBigDecVar() {
  return this.bigDecVar;
}
public void setBigDecVar(final BigDecimal bigDecVar) {
  this.bigDecVar = bigDecVar;
  this.bigDecimalSetterCalled = true;
}

given those inputs:

1. empty tag
<longVar></longVar>
<bigDecVar></bigDecVar>

2. invalid input
<longVar>looooong</longVar>
<bigDecVar>biiiiiig</bigDecVar>

I am observing if the setters are called. On input 2. invalid values - setters are not called. On input 1. empty tags - longSetter is not called, bigDecimalSetter is CALLED. WHY?

And of course on input

3. nil
<longVar xsi:nil="true"></longVar>
<bigDecVar xsi:nil="true"></bigDecVar>

both setters are called, which is what I need.

So, the problem is: when the bigDecimalSetter is called, I cannot tell if the reason is xsi:nil="true", or the value of the tag is invalid (not a BigDecimal). Is there a work-around for that?

user1414745
  • 1,317
  • 6
  • 25
  • 45

0 Answers0