Class MembersTemplate.FieldWithMethod
- Enclosing class:
- MembersTemplate
@Template(src="#{[\'A\',\'B\']}")
public class MembersTemplate.FieldWithMethod
extends java.lang.Object
Template
s. For example, this
is useful, if they share some common properties like the same src or
condition.
Here, for a common src collection ('A', 'B'), a field and a method are generated. So, the resulting members in the generated top level class are: fieldA, methodA, fieldB, methodB.
Japkit does its best to enforce an order of generated elements. However,
this has limitations, since in annotation processing, the order of
elements in TypeElement.getEnclosedElements()
is not as well
defined as one might believe: Javac will (in opposite to JDT) return the
element for the inner class FieldWithMethod BEFORE the element for the
field fixedField. Thus, the generated field order would be fieldA,
fieldB, fixedField instead of fixedField, fieldA, fieldB. To enforce the
ordering, the Order
annotation can be used. This is for example
necessary to generate stable constructor signatures. In the example we
need it for the unit test of the toString method.
If you the order annotation is used on one element, it should be used on all others that need ordering as well. Otherwise, their order will be undefined.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
field$src$
-
Constructor Summary
Constructors Constructor Description FieldWithMethod()
-
Method Summary
Modifier and Type Method Description void
method$src$()
-
Field Details
-
field$src$
java.lang.String field$src$
-
-
Constructor Details
-
FieldWithMethod
public FieldWithMethod()
-
-
Method Details
-
method$src$
public void method$src$()
-