Class ImplementationClassModel

java.lang.Object
org.jboss.logging.processor.generator.model.ClassModel
org.jboss.logging.processor.generator.model.ImplementationClassModel
Direct Known Subclasses:
MessageBundleImplementor, MessageLoggerImplementor

abstract class ImplementationClassModel extends ClassModel
An abstract code model to create the source file that implements the interface.

Essentially this uses the org.jboss.jdeparser.JDeparser to generate the source files with. This class is for convenience in generating default source files.

  • Field Details

    • messageFormatMethodGenerated

      private final AtomicBoolean messageFormatMethodGenerated
    • copyStackTraceMethodGenerated

      private final AtomicBoolean copyStackTraceMethodGenerated
    • stringType

      private final TypeMirror stringType
  • Constructor Details

    • ImplementationClassModel

      ImplementationClassModel(ProcessingEnvironment processingEnv, MessageInterface messageInterface)
      Class constructor.
      Parameters:
      processingEnv - the processing environment
      messageInterface - the message interface to implement.
  • Method Details

    • createBundleMethod

      void createBundleMethod(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter, MessageMethod messageMethod)
      Create the bundle method body.
      Parameters:
      classDef - the class definition
      messageMethod - the message method.
    • createTransformVar

      org.jboss.jdeparser.JAssignableExpr createTransformVar(List<String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, org.jboss.jdeparser.JExpr var)
    • createTransformVar

      org.jboss.jdeparser.JAssignableExpr createTransformVar(List<String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, Transform transform, org.jboss.jdeparser.JExpr var)
    • getUniqueName

      private String getUniqueName(List<String> parameterNames, Parameter parameter, String suffix)
    • getUniqueName

      private String getUniqueName(List<String> parameterNames, StringBuilder sb, int index)
    • addMethodTypeParameters

      private void addMethodTypeParameters(org.jboss.jdeparser.JMethodDef method, TypeMirror type)
    • createReturnType

      private org.jboss.jdeparser.JExpr createReturnType(org.jboss.jdeparser.JClassDef classDef, MessageMethod messageMethod, org.jboss.jdeparser.JBlock body, org.jboss.jdeparser.JCall format, Map<String,org.jboss.jdeparser.JParamDeclaration> fields, Map<String,org.jboss.jdeparser.JParamDeclaration> properties)
    • addThrownTypes

      protected final void addThrownTypes(MessageMethod messageMethod, org.jboss.jdeparser.JMethodDef jMethod)
    • addMethodParameter

      protected org.jboss.jdeparser.JParamDeclaration addMethodParameter(org.jboss.jdeparser.JMethodDef method, Parameter param)
      Adds the parameter to the method returning the reference to the parameter.
      Parameters:
      method - the method to add the parameter to
      param - the parameter to add
      Returns:
      the reference to the parameter on the method
    • addDefultProperties

      private void addDefultProperties(MessageMethod messageMethod, Collection<AnnotationMirror> annotations, org.jboss.jdeparser.JBlock body, org.jboss.jdeparser.JAssignableExpr resultField, boolean field)
    • getFormatMethod

      private org.jboss.jdeparser.JCall getFormatMethod(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter)
      Creates a method for formatting MessageFormat messages. The method should look something like:
           
      
       private String _formatMessage(final String format, final Object... args) {
           final java.text.MessageFormat formatter = new java.text.MessageFormat(format, getLoggingLocale());
           return formatter.format(args, new StringBuffer(), new java.text.FieldPosition(0)).toString();
       }
           
       

      This can be invoked multiple times resulting in only a single method being created in the source.

      Parameters:
      classDef - the class to add the method to
      localeGetter - the getter for the locale
      Returns:
      a method call representation of the _formatMessage(String, Object...) method
    • getCopyStackMethod

      private org.jboss.jdeparser.JCall getCopyStackMethod(org.jboss.jdeparser.JClassDef classDef)