First transformation processor

Goal

We'll make a first transformation that adds a field to a class
and initializes it in the constructor of the current class.

Factories and setters

With Factory (javadoc),
you can get and create all elements of the meta model. For example, if you want
to create a class with the name "Tacos", use the factory to create an empty class
and fill information on the created element to set its name.

dateRef, a CtTypeReference (javadoc),
is created by our factory from Date.class given by Java. We also created listRef which
is created by our factory from List.class and we add our dateRef as actual type argument
which represents the generic type of the list.

We have created a field named "dates", with a private visibility and typed by our previous type reference,
listRef, which is java.util.List<java.util.Date>.

Second, create the constructor. Before the creation of a CtConstructor (javadoc),
create all objects necessary for this constructor and set them in the target constructor.
The constructor has a parameter typed by the same type of the field previously created
and has a body to assign the parameter to the field.

You can convert any string in a CtStatement (javadoc)
with createCodeSnippetStatement(String statement) or in CtExpression (javadoc)
with createCodeSnippetExpression(String expression). In our case, we convert this.dates = dates
in a CtAssignement (javadoc)
with an assignment and an assigned elements.

With this last example, you have created a statement that you have put in a block.
You have created a parameter typed by the same type as the field and
you have put all these objects in the constructor.