You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by um...@comcast.net on 2008/01/03 09:09:42 UTC
[Betwixt]: Writing polymorphic beans
Env: JDK1.6, Betwixt 0.8
I have a bean A which contains a polymorphic reference to a bean B or C via
an interface as follows:
class A {
private IVehicle vehicle;
public IVehicle getVehicle() { ... }
public void setVehicle(final IVehicle v) { ... }
}
class Car implements IVehicle { ... }
class Bus implements IVehicle { ... }
I need to write an instance of A out as follows:
<A>
<car>
<model>...</model>
</car>
</A>
or as
<A>
<bus>
<model>...</model>
</bus>
</A>
If I use a betwixt file as follows:
<info primitiveTypes="attribute">
<element name="A">
<addDefaults/>
</element>
</info>
I get <A><model>...</model></A>
which is clearly wrong. How can I use the PolymorphicReferenceResolver to identify
if <car> or <bus> must be emitted?
Can you point me to a sample?
Thanks,
/U
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org