Class ModifiersTemplate
java.lang.Object
de.japkit.test.members.common.modifiers.ModifiersTemplate
@Clazz(commentExpr="The generated class for the example.")
@RuntimeMetadata
public abstract class ModifiersTemplate
extends java.lang.Object
ModifiersTrigger can either be copied from the template or set conditionally.
The examples here are mainly for fields and methods but apply to constructors and inner classes as well.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModifiersTemplate.AbstractInnerClassTo keep the abstract modifier for a generated class or inner class, keepAbstract must be set to true.classModifiersTemplate.NonAbstractInnerClassTo support method templates without a dummy method body, also the class template containing them needs to be abstract. -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringdynamicallyNonPublicStaticFieldThe expressions for setting modifiers dynamically have precedence over the according modifiers from the template.(package private) java.lang.StringdynamicallyPrivateFieldVisibilities can also be set dynamically.(package private) java.lang.StringfinalFieldFor final fields, code for initialization needs to be provided.private java.lang.StringprivateFieldModifiersTrigger are copied to the generated element.java.lang.StringpublicFieldModifiersTrigger are copied to the generated element.static intpublicStaticFieldModifiersTrigger are copied to the generated element.(package private) inttransientVolatileFieldModifiersTrigger are copied to the generated element. -
Constructor Summary
Constructors Constructor Description ModifiersTemplate() -
Method Summary
Modifier and Type Method Description abstract java.lang.StringnotAbstractMethod()The abstract modifier is removed from methods, if they have rules for generating a code body.
-
Field Details
-
publicField
public java.lang.String publicFieldModifiersTrigger are copied to the generated element.Here: public
-
privateField
private java.lang.String privateFieldModifiersTrigger are copied to the generated element.Here: private
-
publicStaticField
public static int publicStaticFieldModifiersTrigger are copied to the generated element.Here: public static
-
transientVolatileField
transient volatile int transientVolatileFieldModifiersTrigger are copied to the generated element.Here: transient volatile
-
finalField
@Field(initCode="\"initialValue\"") final java.lang.String finalFieldFor final fields, code for initialization needs to be provided.Here, the String literal "initialValue" is generated.
- See Also:
- Constant Field Values
-
dynamicallyPrivateField
@Field(privateCond="#{true}") java.lang.String dynamicallyPrivateFieldVisibilities can also be set dynamically.Here, the generate field is made private based on a boolean expression.
-
dynamicallyNonPublicStaticField
@Field(publicCond="#{false}") public static java.lang.String dynamicallyNonPublicStaticFieldThe expressions for setting modifiers dynamically have precedence over the according modifiers from the template.Here, the generated field is not public, since publicCond evaluates to false. The field is still static, like given by the template.
-
-
Constructor Details
-
ModifiersTemplate
public ModifiersTemplate()
-
-
Method Details
-
notAbstractMethod
@Method(bodyCode="return null;") public abstract java.lang.String notAbstractMethod()The abstract modifier is removed from methods, if they have rules for generating a code body. This allows to write method templates without a dummy method body.Here, the generated method is not abstract, since bodyCode is set.
-