Class MemberNameTemplate

java.lang.Object
de.japkit.test.members.common.name.MemberNameTemplate

@Clazz(commentExpr="The generated class for the example.")
@RuntimeMetadata
public class MemberNameTemplate
extends java.lang.Object
Member names can be copied from the template, set as annotation value (name) or set by evaluating an expression (nameExpr or using $...$-syntax).

The examples here are for fields but apply to methods and inner classes as well. They do not apply to constructors, since they don't have an own name.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    (package private) java.lang.String $simpleName_toFirstLower$3
    Src is always implicit in expressions and can be omitted.
    (package private) java.lang.String $src_simpleName_toFirstLower$2
    The name of the generated field is determined by evaluating the Java EL expression given by an $-delimited Java EL expression in the template for the member. "_" must be used instead of ".".
    (package private) java.lang.String nameFromAV
    The name of the generated field is determined by the annotation value name.
    (package private) java.lang.String nameFromExpr
    The name of the generated field is determined by evaluating the Java EL expression given by nameExpr.
    (package private) java.lang.String nameFromExprWithSrcCollection
    Here, the src is set to the list of fields of the TypeElement for the annotated class SourceExample.
    (package private) java.lang.String prefix$src_simpleName_toFirstLower$2
    Here, toFirstUpper will be applied automatically, since the expression is not at the beginning of the member name.
    (package private) java.lang.String someString1
    The name of the generated field is copied from the template.
  • Constructor Summary

    Constructors 
    Constructor Description
    MemberNameTemplate()  
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • someString1

      java.lang.String someString1
      The name of the generated field is copied from the template. Here "someString1".
    • nameFromAV

      @Field(name="someString2") java.lang.String nameFromAV
      The name of the generated field is determined by the annotation value name. Here it is "someString2".
    • nameFromExpr

      @Field(nameExpr="#{src.simpleName.toFirstLower}1") java.lang.String nameFromExpr
      The name of the generated field is determined by evaluating the Java EL expression given by nameExpr.

      Here it is "memberNameExample1", since the src is the TypeElement for the annotated class SourceExample, and its TypeElement.getSimpleName() is "SourceExample".

    • $src_simpleName_toFirstLower$2

      java.lang.String $src_simpleName_toFirstLower$2
      The name of the generated field is determined by evaluating the Java EL expression given by an $-delimited Java EL expression in the template for the member. "_" must be used instead of ".". Note that this allows only for simple expressions.

      TODO: Shouldn't we apply toFirstLower here automatically?

      The resulting name is "memberNameExample2".

    • prefix$src_simpleName_toFirstLower$2

      java.lang.String prefix$src_simpleName_toFirstLower$2
      Here, toFirstUpper will be applied automatically, since the expression is not at the beginning of the member name. (For demonstration purposes we apply toFirstLower, to transform "MemberNameExample" into "memberNameExample"). The resulting name is "prefixMemberNameExample2".
    • $simpleName_toFirstLower$3

      java.lang.String $simpleName_toFirstLower$3
      Src is always implicit in expressions and can be omitted.

      TODO: Shouldn't we apply toFirstLower here automatically?

      The resulting name is "memberNameExample3".

    • nameFromExprWithSrcCollection

      @Field(src="#{src.enclosedElements.stream().filter(e -> e.kind == \'FIELD\').toList()}", nameExpr="#{src.simpleName}Copy") java.lang.String nameFromExprWithSrcCollection
      Here, the src is set to the list of fields of the TypeElement for the annotated class SourceExample. Thus, there is a field generated for every field in this list. The src in the name expression is each field in that list. Thus, the resulting fields are "srcField1Copy" and "srcField2Copy".
  • Constructor Details