- summary: Factory annotation --> @Factory
Add a @Factory annotation. This will take either a class name or a pair of
attribute type and instanciation factory.
In the first case, it will create instances of the provided type instead of the
return value of the "getter".
In the latter case, it will pass the value of the attribute to a specific
method in the instanciation factory, and instanciate the returned type
from the factory.
This comes to provide an option to use interfaces, which cannot be
instanciated automatically. Also, it comes to provide a solution to using
different classes in arrays of data containing different items, yet with a
similar interface.
For example, consider an example where an XML contains Shape objects,
the array will be of the Shape interface containing the Draw method. The
XML will be, however, parsed to the different Circle, Triangle, Square
objects according to the type of the object, using this annotation.