![]() | ![]() | ![]() | ![]() | ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | ![]() | ![]() | ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]()
|
How to map field(s) as constructor argumentIntended Audience Prerequisites Basic concept Mapping file References Intended AudienceAnyone who wants to map a class in Castor XML and wants to map fields as constructor arguments. This document helps people to get familiar with the basic/advanced concepts of mapping and shows an example. PrerequisitesNone. Basic conceptAssume you have a class Foo, as shown below
As shown above, the Foo class has - in addition to the default constructor, which is required by Castor XML - a second constructor that allows you to specify a custom size at object initialization. Mapping fileHere's the mapping file to instruct Castor XML about the existence of Foo respectively:
The setMethod="%1" fragment above tells Castor to use the size attribute as a constructor argument when calling Foo(int) during instantiation. References
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() ![]() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() | ![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |