But lets start out easy. To declare a property you have to make a method in a mixin type that returns a value of the type Property, and which does not take any parameters. Here's a simple example:
Property<String> name();
This declares a Property of type String with the name "name". The Property interface has methods "get" and "set"
to access and mutate the value, respectively.
For now you will be responsible for implementing these methods, but later on these will be handled automatically, thus reducing Properties to one-liners!
In the Mixin implementation of the interface with the Property declaration you should have an injection of the Property, which is created for you by Qi4j. The injection can be done in a field like this:
@PropertyField Property<String> name;
The PropertyField dependency injection annotation means that Qi4j will inject the Property for you. The field
has the name "name", which matches the name in the interface, and therefore that Property is injected. You can
then implement the method trivially by just returning the "name" field.
Properties can have Constraints just like method parameters. Simply set them on the Property method instead, and they will be applied just as before when you call "set".
Steps for this tutorial:
If you have successfully completed the task, you should end up with the following artifacts;
HelloWorldBehaviour.java
HelloWorldBehaviourMixin.java
HelloWorldComposite.java
HelloWorldState.java
HelloWorldStateMixin.java