Class ClassModel

    • Constructor Summary

      Constructors 
      Constructor Description
      ClassModel​(javax.annotation.processing.ProcessingEnvironment processingEnv, MessageInterface messageInterface, java.lang.String className, java.lang.String superClassName)
      Construct a class model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) org.jboss.jdeparser.JMethodDef addMessageMethod​(MessageMethod messageMethod)
      Adds a method to return the message value.
      (package private) org.jboss.jdeparser.JMethodDef addMessageMethod​(MessageMethod messageMethod, java.lang.String messageValue)
      Adds a method to return the message value.
      (package private) org.jboss.jdeparser.JCall createLocaleGetter​(java.lang.String locale, boolean override)
      Creates the method used to get the locale for formatting messages.
      protected org.jboss.jdeparser.JMethodDef createReadResolveMethod()
      Creates the read resolve method and instance field.
      private org.jboss.jdeparser.JExpr determineLocale​(java.lang.String locale, org.jboss.jdeparser.JType localeType)  
      void generateAndWrite()
      Writes the generated source file to the file system.
      (package private) org.jboss.jdeparser.JClassDef generateModel()
      Generate the code corresponding to this class model
      MessageInterface messageInterface()
      Returns the message interface being used.
      java.lang.String qualifiedClassName()
      Get the class name.
      • Methods inherited from class java.lang.Object

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

      • INSTANCE_FIELD_NAME

        private static final java.lang.String INSTANCE_FIELD_NAME
        See Also:
        Constant Field Values
      • GET_INSTANCE_METHOD_NAME

        private static final java.lang.String GET_INSTANCE_METHOD_NAME
        See Also:
        Constant Field Values
      • sources

        private final org.jboss.jdeparser.JSources sources
      • classDef

        private final org.jboss.jdeparser.JClassDef classDef
      • className

        private final java.lang.String className
      • superClassName

        private final java.lang.String superClassName
      • format

        private final java.lang.String format
      • messageMethods

        private final java.util.Map<java.lang.String,​org.jboss.jdeparser.JMethodDef> messageMethods
      • sourceFile

        final org.jboss.jdeparser.JSourceFile sourceFile
      • processingEnv

        final javax.annotation.processing.ProcessingEnvironment processingEnv
    • Constructor Detail

      • ClassModel

        ClassModel​(javax.annotation.processing.ProcessingEnvironment processingEnv,
                   MessageInterface messageInterface,
                   java.lang.String className,
                   java.lang.String superClassName)
        Construct a class model.
        Parameters:
        processingEnv - the processing environment
        messageInterface - the message interface to implement.
        superClassName - the super class used for the translation implementations.
    • Method Detail

      • messageInterface

        public final MessageInterface messageInterface()
        Returns the message interface being used.
        Returns:
        the message interface.
      • generateAndWrite

        public final void generateAndWrite()
                                    throws java.io.IOException
        Writes the generated source file to the file system.
        Throws:
        java.io.IOException - if the file could not be written
      • generateModel

        org.jboss.jdeparser.JClassDef generateModel()
                                             throws java.lang.IllegalStateException
        Generate the code corresponding to this class model
        Returns:
        the generated code
        Throws:
        java.lang.IllegalStateException - if the class has already been defined.
      • addMessageMethod

        org.jboss.jdeparser.JMethodDef addMessageMethod​(MessageMethod messageMethod)
        Adds a method to return the message value. The method name should be the method name annotated org.jboss.logging.Message. This method will be appended with $str.

        If the message method has already been defined the previously created method is returned.

        Parameters:
        messageMethod - the message method
        Returns:
        the newly created method.
        Throws:
        java.lang.IllegalStateException - if this method is called before the generateModel method
      • addMessageMethod

        org.jboss.jdeparser.JMethodDef addMessageMethod​(MessageMethod messageMethod,
                                                        java.lang.String messageValue)
        Adds a method to return the message value. The method name should be the method name annotated org.jboss.logging.Message. This method will be appended with $str.

        If the message method has already been defined the previously created method is returned.

        Parameters:
        messageMethod - the message method.
        messageValue - the message value.
        Returns:
        the newly created method.
        Throws:
        java.lang.IllegalStateException - if this method is called before the generateModel method
      • qualifiedClassName

        public final java.lang.String qualifiedClassName()
        Get the class name.
        Returns:
        the class name
      • createReadResolveMethod

        protected org.jboss.jdeparser.JMethodDef createReadResolveMethod()
        Creates the read resolve method and instance field.
        Returns:
        the read resolve method.
      • createLocaleGetter

        org.jboss.jdeparser.JCall createLocaleGetter​(java.lang.String locale,
                                                     boolean override)
        Creates the method used to get the locale for formatting messages.

        If the locale parameter is null the MessageLogger.rootLocale() or MessageBundle.rootLocale() will be used to determine the locale to use.

        Parameters:
        locale - the locale to use
        override - true if the Override annotation should be added to the method
        Returns:
        the call to the locale getter
      • determineLocale

        private org.jboss.jdeparser.JExpr determineLocale​(java.lang.String locale,
                                                          org.jboss.jdeparser.JType localeType)