Class JavaCodeFragmentBuilder

java.lang.Object
org.faktorips.codegen.JavaCodeFragmentBuilder

public class JavaCodeFragmentBuilder extends Object
A builder to create JavaCodeFragments with a uniform coding style.

JavaCodeFragmentBuilder uses the method chaining pattern: Every method modifying the JavaCodeFragment returns this JavaCodeFragmentBuilder so you could chain the methods as follows: javaCodeFragmentBuilder.methodBegin(<method signature parameter>).appendLn(<one line>).methodEnd();.

  • Constructor Details

    • JavaCodeFragmentBuilder

      public JavaCodeFragmentBuilder()
      Creates a new fragment builder to build Java source code.
    • JavaCodeFragmentBuilder

      public JavaCodeFragmentBuilder(boolean indent)
      Creates a new fragment builder to build Java source code.
  • Method Details

    • getFragment

      public JavaCodeFragment getFragment()
      Returns the fragment under construction.
    • addImport

      public JavaCodeFragmentBuilder addImport(String qualifiedClassName)
      Adds an import entry to the code fragment under construction.
      Parameters:
      qualifiedClassName - the java class that is added to the import declaration
    • addImport

      public JavaCodeFragmentBuilder addImport(Class<?> clazz)
      Adds an import entry to the code fragment under construction.
    • appendln

      public JavaCodeFragmentBuilder appendln()
      Appends a line separator to fragment's source code.
    • append

      public JavaCodeFragmentBuilder append(String s)
      Appends the given String to the fragment's source code.
    • appendQuoted

      public JavaCodeFragmentBuilder appendQuoted(String s)
      Encloses the given String with double quotes (") and appends it to fragment.
    • append

      public JavaCodeFragmentBuilder append(char c)
      Appends the given char to the fragment's source code.
    • append

      public JavaCodeFragmentBuilder append(int i)
      Appends the given int to the fragment's source code.
    • appendClassName

      public JavaCodeFragmentBuilder appendClassName(Class<?> clazz)
      Appends the class' unqualified name to the source code and updates the import declaration (if necessary).
    • appendClassName

      public JavaCodeFragmentBuilder appendClassName(String qualifiedClassName)
      Appends the unqualified class name to the source code and updates the import declaration (if necessary).
    • appendln

      public JavaCodeFragmentBuilder appendln(String s)
      Appends the given String and a line separator to the fragment's source code.
    • appendln

      public JavaCodeFragmentBuilder appendln(char c)
      Appends the given char to the fragment's source code.
    • append

      public JavaCodeFragmentBuilder append(JavaCodeFragment fragment)
      Appends the given fragment to the fragment under construction and indents it properly.
    • appendJavaModifier

      public JavaCodeFragmentBuilder appendJavaModifier(int modifier)
      Append the Java modifier translated to a String, e.g. for java.lang.reflect.Modifier.PUBLIC "public" is appended.
      Parameters:
      modifier - Modifier according to java.lang.reflect.Modifier
      See Also:
    • openBracket

      public JavaCodeFragmentBuilder openBracket()
      Adds an opening bracket followed by a newline and increases the indentation level by one afterwards.
    • closeBracket

      public JavaCodeFragmentBuilder closeBracket()
      Adds a closing bracket and decreases the indentation level by one afterwards.
    • method

      public JavaCodeFragmentBuilder method(int modifier, String returnType, String methodName, String[] argName, String[] argClass, JavaCodeFragment body, String javadoc)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - The className that the methods returns an instance of or null to indicate no return type in case of a constructor. The return type void is indicated by java.lang.Void.class:
      argName - Argument names.
      argClass - Argument classes.
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, Class<?>[] exceptionClasses)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - The className that the methods returns an instance of or null to indicate no return type in case of a constructor. The return type void is indicated by java.lang.Void.class:
      argName - Argument names.
      argClass - Argument classes.
    • method

      public JavaCodeFragmentBuilder method(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, JavaCodeFragment body, String javadoc)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
    • method

      public JavaCodeFragmentBuilder method(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, Class<?>[] exceptionClasses, JavaCodeFragment body, String javadoc)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      exceptionClasses - Exception classes that can be thrown by the generated method
      body - the method body
      javadoc - the java documentation
    • method

      public JavaCodeFragmentBuilder method(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, JavaCodeFragment body, String javadoc, String... javaDocAnnotations)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
      javaDocAnnotations - annotations of the java documentation
    • method

      public JavaCodeFragmentBuilder method(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, JavaCodeFragment body, String javadoc, String[] javaDocAnnotations, String[] annotations)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
      javaDocAnnotations - annotations of the java documentation
      annotations - Java 5 annotations
    • method

      public JavaCodeFragmentBuilder method(int modifier, String returnType, String methodName, String[] argName, String[] argClass, JavaCodeFragment body, String javadoc, String... javaDocAnnotations)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
      javaDocAnnotations - annotations of the java documentation
    • method

      public JavaCodeFragmentBuilder method(int modifier, String returnType, String methodName, String[] argName, String[] argClass, JavaCodeFragment body, String javadoc, String[] javaDocAnnotations, String[] annotations)
      Creates the Java source code for a method including signature, body and java doc.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor
      methodName - the name of the method.
      argName - Argument names.
      argClass - Argument classes.
      body - the method body
      javadoc - the java documentation
      javaDocAnnotations - annotations of the java documentation
      annotations - Java 5 annotations
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, String returnType, String methodName, String[] argName, String[] argClass, String javaDoc)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      javaDoc - the java documentation for this method signature
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, String returnType, String methodName, String[] argName, String[] argClass, String javaDoc, String[] javaDocAnnotations)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      javaDoc - the java documentation for this method signature
      javaDocAnnotations - annotations of the java documentation
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, Class<?> returnType, String methodName, String[] argName, Class<?>[] argClass, String javaDoc, String[] javaDocAnnotations)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      javaDoc - the java documentation for this method signature
      javaDocAnnotations - annotations of the java documentation
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, String returnType, String methodName, String[] argName, String[] argClass)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
    • methodBegin

      public JavaCodeFragmentBuilder methodBegin(int modifier, String returnType, String methodName, String[] argName, String[] argClass, String[] exceptionClasses)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, String returnType, String methodName, String[] argName, String[] argClass)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, JavaCodeFragment returnType, String methodName, String[] argName, String[] argClass)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, String returnType, String methodName, String[] argName, String[] argClass, boolean argFinal)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      argFinal - indicates if the arguments are prefix be a final modifier
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, String returnType, String methodName, String[] argName, String[] argClass, String[] exceptionClasses)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      exceptionClasses - the thrown exceptions
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, JavaCodeFragment returnType, String methodName, String[] argName, String[] argClass, String[] exceptionClasses)
      Creates the Java source code for a method signature.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      exceptionClasses - the thrown exceptions
    • signature

      public JavaCodeFragmentBuilder signature(int modifier, String returnType, String methodName, String[] argName, String[] argClass, String javaDoc, String[] javaDocAnnotations)
      Creates the Java source code for a method signature. If the method is non abstract the generated code ends with an opening bracket '{'. If the method is abstract the code ends with the argument list's closing bracket ')'.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      returnType - the className that the methods returns an instance of or null to indicate no return type in case of a constructor.
      argName - Argument names.
      argClass - Argument classes.
      javaDoc - the java documentation for this method signature
      javaDocAnnotations - annotations of the java documentation
    • methodEnd

      public JavaCodeFragmentBuilder methodEnd()
      Appends the source code for the the end of a method. If the method is abstract a semicolon is generated, otherwise a closing bracket. If the method is abstract or not, is determined from the modifier used in the last call to methodBegin().
    • classBegin

      public JavaCodeFragmentBuilder classBegin(int modifier, String className)
      Appends the source code for the beginning of a new class at the end of the fragment under construction.
    • classBegin

      public JavaCodeFragmentBuilder classBegin(int modifier, String className, Class<?> extendsClass, Class<?>[] interfaces)
      Appends the source code for the beginning of a new class at the end of the fragment under construction.
    • classBegin

      public JavaCodeFragmentBuilder classBegin(int modifier, String className, String extendsClassName, String[] interfaces)
      Appends the source code for the beginning of a new class at the end of the fragment under construction.
    • enumBegin

      public JavaCodeFragmentBuilder enumBegin(int modifier, String className, String extendsClassName, String[] interfaces)
      Appends the source code for the beginning of a new enum at the end of the fragment under construction.
    • classEnd

      public JavaCodeFragmentBuilder classEnd()
      Writes the code at the end of a class.
    • interfaceBegin

      public JavaCodeFragmentBuilder interfaceBegin(String interfaceName)
      Appends the source code for the beginning of a new interface at the end of the fragment under construction.
    • interfaceBegin

      public JavaCodeFragmentBuilder interfaceBegin(String interfaceName, String extendsInterfaceName)
      Appends the source code for the beginning of a new interface at the end of the fragment under construction.
    • interfaceBegin

      public JavaCodeFragmentBuilder interfaceBegin(String interfaceName, String[] extendedInterfaces)
      Appends the source code for the beginning of a new interface at the end of the fragment under construction.
    • varDeclaration

      public JavaCodeFragmentBuilder varDeclaration(int modifier, Class<?> clazz, String varName)
      Creates a new variable declaration.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      clazz - The class the variable is an instance of
      varName - the variable's name.
    • varDeclaration

      public JavaCodeFragmentBuilder varDeclaration(int modifier, Class<?> clazz, String varName, JavaCodeFragment expression)
      Creates a new variable declaration.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      clazz - The class the variable is an instance of
      varName - the variable's name.
      expression - the initial value of the variable
    • varDeclaration

      public JavaCodeFragmentBuilder varDeclaration(int modifier, String className, String varName, JavaCodeFragment expression)
      Creates a new variable declaration.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      className - The class' name the variable is an instance of
      varName - the variable's name.
      expression - the initial value of the variable
    • varDeclaration

      public JavaCodeFragmentBuilder varDeclaration(int modifier, JavaCodeFragment className, String varName, JavaCodeFragment expression)
      Creates a new variable declaration.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      className - The class' name the variable is an instance of
      varName - the variable's name.
      expression - the initial value of the variable
    • varDeclaration

      public JavaCodeFragmentBuilder varDeclaration(int modifier, String className, String varName)
      Creates a new variable declaration.
      Parameters:
      modifier - Access modifier according to java.lang.reflect.Modifier.
      className - The class' name the variable is an instance of
      varName - the variable's name.
    • varDefinition

      public JavaCodeFragmentBuilder varDefinition(Class<?> varClass, String varName, String varValue)
      Writes a variable definition.
    • varDefinition

      public JavaCodeFragmentBuilder varDefinition(String classOrTypeName, String variableName, String variableValue)
      Writes a variable definition.
    • assignment

      public JavaCodeFragmentBuilder assignment(String variable, JavaCodeFragment expression)
      Appends a new assignment. varName = value;
    • assignment

      public JavaCodeFragmentBuilder assignment(String variable, String value)
      Creates a new variable declaration. varName = value;
    • singleLineComment

      public JavaCodeFragmentBuilder singleLineComment(String comment)
    • multiLineComment

      public JavaCodeFragmentBuilder multiLineComment(String comment)
    • javaDoc

      public JavaCodeFragmentBuilder javaDoc(String text, String... annotations)
      Puts the given text and annotations into a java doc comment. For an annotation only the annotation name and optionally separated by a space character an annotation text needs to be specified. The '@' character will be automatically added.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(Class<?>... annotations)
      Writes each annotation with a line separator. Import statements are added automatically to the code fragment (if needed).
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(Class<?> annotation, String params)
      Writes the annotation with the indicated parameters and a line separator. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
      Parameters:
      annotation - The annotation class
      params - Parameters for the annotation without parenthesis. If null or an empty String, parenthesis aren't added.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(Class<?> annotation, JavaCodeFragment params)
      Writes the annotation with the indicated parameters and a line separator. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
      Parameters:
      annotation - The annotation class
      params - Parameters for the annotation without parenthesis. If empty, parenthesis aren't added.
    • annotation

      public JavaCodeFragmentBuilder annotation(Class<?> annotation, JavaCodeFragment params)
      Writes the annotation with the indicated parameters and a line separator. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
      Parameters:
      annotation - The annotation class
      params - Parameters for the annotation without parenthesis. If empty, parenthesis aren't added.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(Class<?> annotation, String paramName, String stringValue)
      Writes the annotation with the indicated parameter of type String and adds a line separator. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
       Example
         annotation : javax.xml.bind.annotation.XmlRootElement
         paramName  : name
         stringValue: policy
         Result: @XmlElement(name="Policy")
       
      Parameters:
      annotation - The annotation class
      paramName - The name of the parameter
      stringValue - The unquoted string value for the parameter. This method generates the quotes.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(String annotation, JavaCodeFragment params)
      Writes the annotation with the indicated parameters. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
      Parameters:
      annotation - The annotation class
      params - Parameters for the annotation without parenthesis. If null or an empty String, parenthesis aren't added.
    • annotation

      public JavaCodeFragmentBuilder annotation(String annotation, JavaCodeFragment params)
      Writes the annotation with the indicated parameters. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
      Parameters:
      annotation - The annotation class
      params - Parameters for the annotation without parenthesis. If null or an empty String, parenthesis aren't added.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(String annotation, String params)
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(String annotation, String paramName, String stringValue)
      Writes the annotation with the indicated parameter of type String. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
       Example
         annotation : javax.xml.bind.annotation.XmlRootElement
         paramName  : name
         stringValue: policy
         Result: @XmlElement(name="policy")
       
      Parameters:
      annotation - The annotation class
      paramName - The name of the parameter
      stringValue - The unquoted string value for the parameter. This method generates the quotes.
    • annotation

      public JavaCodeFragmentBuilder annotation(String annotation, String paramName, String stringValue)
      Writes the annotation with the indicated parameter of type String. '@' character will be automatically added. Import statements are added automatically to the code fragment (if needed).
       Example
         annotation : javax.xml.bind.annotation.XmlRootElement
         paramName  : name
         stringValue: policy
         Result: @XmlElement(name="policy")
       
      Parameters:
      annotation - The annotation class
      paramName - The name of the parameter
      stringValue - The unquoted string value for the parameter. This method generates the quotes.
    • annotationClassValueLn

      public JavaCodeFragmentBuilder annotationClassValueLn(String annotation, String paramName, String qualifiedClassName)
      Writes the annotation for a class value. '@' character and a line feed will be automatically added. Import statements are added automatically to the code fragment (if needed).
       Example
         annotation : javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter
         paramName  : value
         qualifiedClassName: EnumValueXmlAdapter
         Result: @XmlJavaTypeAdapter(value = EnumValueXmlAdapter.class)
       
      Parameters:
      annotation - The annotation class
      paramName - The name of the parameter
      qualifiedClassName - The class value for the parameter
    • annotation

      public JavaCodeFragmentBuilder annotation(String[] annotations)
      Writes the annotations. For an annotation only the annotation name needs to be specified. The '@' character and a line feed will be automatically added.
    • annotationLn

      public JavaCodeFragmentBuilder annotationLn(String annotation)
      Writes the annotation. For an annotation the (fully qualified) annotation class name needs to be specified. The '@' character and a line feed will be automatically added. The annotation may contain parameters in parenthesis.
      Parameters:
      annotation - The fully qualified annotation name with parameters
    • methodCall

      public JavaCodeFragmentBuilder methodCall(String name, String[] parameters, boolean finishLine)
      Writes a method call to the java code fragment builder.
      Parameters:
      name - The name of the method to call
      parameters - the parameters for the method call
      Returns:
      the fragment builder for method chaining
    • methodCall

      public JavaCodeFragmentBuilder methodCall(String name, JavaCodeFragment[] parameterFragments, boolean finishLine)
      Writes a method call to the java code fragment builder.
      Parameters:
      name - The name of the method to call
      parameterFragments - the parameters for the method call
      Returns:
      the fragment builder for method chaining
    • methodCall

      public JavaCodeFragmentBuilder methodCall(String name, List<String> parameters, boolean finishLine)
      Parameters:
      name - the name of the method
      parameters - the list of parameters
      Returns:
      the fragment builder for method chaining
      See Also:
    • constructorCall

      public JavaCodeFragmentBuilder constructorCall(String className, String[] parameters, boolean finishLine)
      append a constructor call: new <name>(parameters[0], parameters[1], ...)
      Parameters:
      finishLine - append a semicolon and new line if true
      Returns:
      the JavaCodeFragmentBuilder for Method chaining
    • constructorCall

      public JavaCodeFragmentBuilder constructorCall(String className, List<String> parameters, boolean finishLine)
      Returns:
      The created instance of JavaCodeFragmentBuilder
      See Also:
    • appendParameters

      public JavaCodeFragmentBuilder appendParameters(String[] parameters)
    • appendParameters

      public JavaCodeFragmentBuilder appendParameters(JavaCodeFragment[] parameters)
    • appendGenerics

      public JavaCodeFragmentBuilder appendGenerics(String... classNames)
      Appends the generic parameters to the builder: <className1, className2, ...>. An import statement is added if a given class has not yet been imported.

      Note: You have to make sure that generics are supported by target compiler

    • appendGenerics

      public JavaCodeFragmentBuilder appendGenerics(Class<?>... classes)
      Appends the generic parameters to the builder: <class1, class2, ...>. An import statement is added if a given class has not yet been imported.

      Note: You have to make sure that generics are supported by target compiler

    • appendJoin

      public JavaCodeFragmentBuilder appendJoin(List<JavaCodeFragment> parts, String separator)
    • toString

      public String toString()
      Overrides:
      toString in class Object