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

public abstract class ClassModel extends Object
The basic java class model.
  • Field Details

    • INSTANCE_FIELD_NAME

      private static final String INSTANCE_FIELD_NAME
      See Also:
    • GET_INSTANCE_METHOD_NAME

      private static final String GET_INSTANCE_METHOD_NAME
      See Also:
    • sources

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

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

      private final MessageInterface messageInterface
    • className

      private final String className
    • superClassName

      private final String superClassName
    • format

      private final String format
    • messageMethods

      private final Map<String,org.jboss.jdeparser.JMethodDef> messageMethods
    • sourceFile

      final org.jboss.jdeparser.JSourceFile sourceFile
    • processingEnv

      final ProcessingEnvironment processingEnv
  • Constructor Details

    • ClassModel

      ClassModel(ProcessingEnvironment processingEnv, MessageInterface messageInterface, String className, 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 Details

    • messageInterface

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

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

      org.jboss.jdeparser.JClassDef generateModel() throws IllegalStateException
      Generate the code corresponding to this class model
      Returns:
      the generated code
      Throws:
      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:
      IllegalStateException - if this method is called before the generateModel method
    • addMessageMethod

      org.jboss.jdeparser.JMethodDef addMessageMethod(MessageMethod messageMethod, 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:
      IllegalStateException - if this method is called before the generateModel method
    • qualifiedClassName

      public final 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(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(String locale, org.jboss.jdeparser.JType localeType)