The ConstructorFor annotation allows the jsba runtime to decide which constructor to use for building jsba objects from the tuples in a relation returned from a query.
The jsba runtime searches for and selects the constructor to use in the following order of preference :
- A public constructor with a single argument of a type/class that implements the
Tuple
interface. It is the responsibility of the designer to ensure that only one such constructor exists. If more than one such constructor exists, results are unpredictable.
- A public constructor annotated by a ConstructorFor annotation. The constructor selected will be the one that :
- names a subset of the attributes present in the tuple's heading, i.e. no attributes are named in the annotation that are not present in the tuple
- has the highest attribute count
It is the responsibility of the designer to ensure that only one such constructor exists (i.e. there cannot be 'draws' in terms of attribute count). If more than one such constructors can be found, results are unpredictable.
- A public no-arg constructor.