Class ConstructorExampleGen
@ConstructorTrigger(shadow=true) @Generated(src="de.japkit.test.members.constructor.ConstructorExample") public class ConstructorExampleGen extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description (package private) int
field1
Copies the fields fromConstructorExample
.(package private) java.lang.String
field2
Copies the fields fromConstructorExample
.(package private) java.lang.String
field3
Copies the fields fromConstructorExample
. -
Constructor Summary
Constructors Constructor Description ConstructorExampleGen()
A parameterless constructor.ConstructorExampleGen(int dummy, int field1, java.lang.String field2, java.lang.String field3)
The same as#ConstructorTemplate(SrcType)
.ConstructorExampleGen(int field1, java.lang.String field2, java.lang.String field3)
A constructor that has the fields of the annotated class (MembersExample
) as parameters and assigns them to the according generated fields.ConstructorExampleGen(java.lang.String field2)
For constructors with at least one parameter, theConstructor
annotation is not necessary. -
Method Summary
-
Field Details
-
field1
int field1Copies the fields fromConstructorExample
. -
field2
java.lang.String field2Copies the fields fromConstructorExample
. -
field3
java.lang.String field3Copies the fields fromConstructorExample
.
-
-
Constructor Details
-
ConstructorExampleGen
public ConstructorExampleGen()A parameterless constructor. When it is generated in the target class, the name will we be adjusted accordingly.The
Constructor
annotation is required for disambiguation when generating a default constructor. -
ConstructorExampleGen
public ConstructorExampleGen(java.lang.String field2)For constructors with at least one parameter, theConstructor
annotation is not necessary. -
ConstructorExampleGen
public ConstructorExampleGen(int field1, java.lang.String field2, java.lang.String field3)A constructor that has the fields of the annotated class (MembersExample
) as parameters and assigns them to the according generated fields.The parameter order depends on the result of
TypeElement#getEnclosedElements()
, which is used infields
function. Usually, this will be the same order as in the source code ofConstructorExample
. However, during incremental build in Eclipse, you may sometimes experience a different order. If this happens, please do a clean build.- See Also:
- Eclipse Bug 300408, Eclipse Bug 500589
-
ConstructorExampleGen
public ConstructorExampleGen(int dummy, int field1, java.lang.String field2, java.lang.String field3)The same as#ConstructorTemplate(SrcType)
. But this time, aCodeFragment
is called for generating the field assignment code. A CodeFragment is basically a function that creates code.By using CodeFragments, arbitrary complex constructors and methods can be generated. But as in manual programming, it might be sometimes better to split them into multiple (private) methods then.
Note that there a important differences between a CodeFragment and a function that returns a string. For example, CodeFragments provide support for adding import statements to the generated class. Furthermore, they are evaluated lazily, when the generated class is finally written. So, do not use simple string functions when generating method or constructor bodies, but always CodeFragments.
-