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 class
ImplementationClassModel.JExprAnnotationValueVisitor
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
copyStackTraceMethodGenerated
private java.util.concurrent.atomic.AtomicBoolean
messageFormatMethodGenerated
private javax.lang.model.type.TypeMirror
stringType
-
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 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 formattingMessageFormat
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 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 formattingMessageFormat
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 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)
-
-