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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classImplementationClassModel.JExprAnnotationValueVisitor
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBooleancopyStackTraceMethodGeneratedprivate java.util.concurrent.atomic.AtomicBooleanmessageFormatMethodGeneratedprivate javax.lang.model.type.TypeMirrorstringType-
Fields inherited from class org.jboss.logging.processor.generator.model.ClassModel
processingEnv, sourceFile
-
-
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 voidaddDefultProperties(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.JParamDeclarationaddMethodParameter(org.jboss.jdeparser.JMethodDef method, Parameter param)Adds the parameter to the method returning the reference to the parameter.private voidaddMethodTypeParameters(org.jboss.jdeparser.JMethodDef method, javax.lang.model.type.TypeMirror type)protected voidaddThrownTypes(MessageMethod messageMethod, org.jboss.jdeparser.JMethodDef jMethod)(package private) voidcreateBundleMethod(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter, MessageMethod messageMethod)Create the bundle method body.private org.jboss.jdeparser.JExprcreateReturnType(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.JAssignableExprcreateTransformVar(java.util.List<java.lang.String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, org.jboss.jdeparser.JExpr var)(package private) org.jboss.jdeparser.JAssignableExprcreateTransformVar(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.JCallgetCopyStackMethod(org.jboss.jdeparser.JClassDef classDef)private org.jboss.jdeparser.JCallgetFormatMethod(org.jboss.jdeparser.JClassDef classDef, org.jboss.jdeparser.JCall localeGetter)Creates a method for formattingMessageFormatmessages.private java.lang.StringgetUniqueName(java.util.List<java.lang.String> parameterNames, java.lang.StringBuilder sb, int index)private java.lang.StringgetUniqueName(java.util.List<java.lang.String> parameterNames, Parameter parameter, java.lang.String suffix)-
Methods inherited from class org.jboss.logging.processor.generator.model.ClassModel
addMessageMethod, addMessageMethod, createLocaleGetter, createReadResolveMethod, generateAndWrite, generateModel, messageInterface, qualifiedClassName
-
-
-
-
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 environmentmessageInterface- 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 definitionmessageMethod- 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 toparam- 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 formattingMessageFormatmessages. 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 tolocaleGetter- 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)
-
-