Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] MOXY: Map empty element as Boolean


I have this class;

class Foo {
  Boolean something;
}


This xml:

<foo>
  <something/>
</foo>

...should create a mapped instance that has something = Boolean.TRUE;

This xml:

<foo>
</foo>

...should create a mapped instance that has something = Boolean.FALSE;

How can I do this? I cannot find a way to map this to a Boolean. 

Right now I create a descriptor for a dummy class, and map that instead of the boolean. Then i get null or dummy object instead of false and true

        XMLChoiceObjectMapping something = new XMLChoiceObjectMapping();
        something.setAttributeName("something");
        allvarligtFelIR.addChoiceElement("something", Dummy.class);

But this feels wrong, and I really want a Boolean....

Thanks!

--

  /Magnus Heino

Back to the top