Class 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.

    • Constructor Summary

      Constructors 
      Constructor Description
      ImplementationClassModel​(javax.annotation.processing.ProcessingEnvironment processingEnv, MessageInterface messageInterface)
      Class constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addDefultProperties​(MessageMethod messageMethod, java.util.Collection<javax.lang.model.element.AnnotationMirror> annotations, org.jboss.jdeparser.JBlock body, org.jboss.jdeparser.JAssignableExpr resultField, boolean field)  
      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.
      private void addMethodTypeParameters​(org.jboss.jdeparser.JMethodDef method, javax.lang.model.type.TypeMirror type)  
      protected void addThrownTypes​(MessageMethod messageMethod, org.jboss.jdeparser.JMethodDef jMethod)  
      (package private) void createBundleMethod​(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter, MessageMethod messageMethod)
      Create the bundle method body.
      private org.jboss.jdeparser.JExpr createReturnType​(org.jboss.jdeparser.JClassDef classDef, MessageMethod messageMethod, org.jboss.jdeparser.JBlock body, org.jboss.jdeparser.JCall format, java.util.Map<java.lang.String,​org.jboss.jdeparser.JParamDeclaration> fields, java.util.Map<java.lang.String,​org.jboss.jdeparser.JParamDeclaration> properties)  
      (package private) org.jboss.jdeparser.JAssignableExpr createTransformVar​(java.util.List<java.lang.String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, org.jboss.jdeparser.JExpr var)  
      (package private) org.jboss.jdeparser.JAssignableExpr createTransformVar​(java.util.List<java.lang.String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, Transform transform, org.jboss.jdeparser.JExpr var)  
      private org.jboss.jdeparser.JCall getCopyStackMethod​(org.jboss.jdeparser.JClassDef classDef)  
      private org.jboss.jdeparser.JCall getFormatMethod​(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter)
      Creates a method for formatting MessageFormat messages.
      private java.lang.String getUniqueName​(java.util.List<java.lang.String> parameterNames, java.lang.StringBuilder sb, int index)  
      private java.lang.String getUniqueName​(java.util.List<java.lang.String> parameterNames, Parameter parameter, java.lang.String suffix)  
      • Methods inherited from class java.lang.Object

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

      • messageFormatMethodGenerated

        private final java.util.concurrent.atomic.AtomicBoolean messageFormatMethodGenerated
      • copyStackTraceMethodGenerated

        private final java.util.concurrent.atomic.AtomicBoolean copyStackTraceMethodGenerated
      • stringType

        private final javax.lang.model.type.TypeMirror stringType
    • Constructor Detail

      • ImplementationClassModel

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

      • 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​(java.util.List<java.lang.String> parameterNames,
                                                               org.jboss.jdeparser.JBlock methodBody,
                                                               Parameter param,
                                                               org.jboss.jdeparser.JExpr var)
      • createTransformVar

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

        private java.lang.String getUniqueName​(java.util.List<java.lang.String> parameterNames,
                                               Parameter parameter,
                                               java.lang.String suffix)
      • getUniqueName

        private java.lang.String getUniqueName​(java.util.List<java.lang.String> parameterNames,
                                               java.lang.StringBuilder sb,
                                               int index)
      • addMethodTypeParameters

        private void addMethodTypeParameters​(org.jboss.jdeparser.JMethodDef method,
                                             javax.lang.model.type.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,
                                                           java.util.Map<java.lang.String,​org.jboss.jdeparser.JParamDeclaration> fields,
                                                           java.util.Map<java.lang.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,
                                         java.util.Collection<javax.lang.model.element.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)