Derived BeansWhat Is A Derived Bean?A derived bean is one whose runtime class differs from the mapped property type (as determined during introspection). Specifying The Bind Time TypeUsing An Attribute To Specify Class
An easy way to specify the class to be loaded is for the class name to be
specified by an xml attribute. By default, the For example the following xml: <Animals> <animal className='org.apache.commons.betwixt.io.read.FerretBean'> <call>Dook</call> <colour>albino</colour> <latinName>Mustela putoris furo</latinName> <name>Lector</name> </animal> <animal className='org.apache.commons.betwixt.io.read.CatBean'> <call>Meow</call> <colour>black</colour> <latinName>Felis catus</latinName> <name>Sam</name> </animal> <animal className='org.apache.commons.betwixt.io.read.DogBean'> <breed>mongrol</breed> <call>Woof</call> <latinName>Canis familiaris</latinName> <name>Bobby</name> <pedigree>false</pedigree> </animal> </Animals>
will construct objects of type
The attribute which contains the fully qualified class name can be configured through
the
The classname mapping is implemented by a Mapping Derived BeansBind Time Type Verses Introspection Time Type
The introspection time type is the (expected) type as discovered during introspection.
The bind time type is the actual type of the object found as Betwixt runs. For example,
a property might have type There are two approaches to deal with this situation: either the object can be mapped on the basis of it's bind time type (the actual class of the object) or on the basis of it's introspection time type. In the first case, all the properties present will be mapped, in the second only a subset.
For example, say that There are typical use cases which demonstate the need for each approach. Betwixt supports both in a flexible way, for both reading and writing but defaults to bind time typing (which is typically more intuitive). Configuring Mapping Derivation
Whether the bind time type or the introspection time type should determine the mapping
is configurable in two different ways. The
For example, the following code snippet configures an XMLIntrospector xmlIntrospector = ...; xmlIntrospector.getConfiguration() .setMappingDerivationStrategy( MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE); }
The optional
For example, when the following dot betwixt document is used, the <?xml version='1.0'?> <info> <element name='pet-record'> <element name='pet' property='pet' mappingDerivation='introspection'/>" + </element> </info>" }
Note that the mapping derivations are added together with all of the other defaults
and so all elements without the |