Class ImplementationClassModel
java.lang.Object
org.jboss.logging.processor.generator.model.ClassModel
org.jboss.logging.processor.generator.model.ImplementationClassModel
- Direct Known Subclasses:
MessageBundleImplementor, MessageLoggerImplementor
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 ClassesModifier and TypeClassDescriptionprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicBooleanprivate final AtomicBooleanprivate final TypeMirrorFields inherited from class ClassModel
processingEnv, sourceFile -
Constructor Summary
ConstructorsConstructorDescriptionImplementationClassModel(ProcessingEnvironment processingEnv, MessageInterface messageInterface) Class constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddDefultProperties(MessageMethod messageMethod, Collection<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, TypeMirror type) protected final 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, Map<String, org.jboss.jdeparser.JParamDeclaration> fields, Map<String, org.jboss.jdeparser.JParamDeclaration> properties) (package private) org.jboss.jdeparser.JAssignableExprcreateTransformVar(List<String> parameterNames, org.jboss.jdeparser.JBlock methodBody, Parameter param, org.jboss.jdeparser.JExpr var) (package private) org.jboss.jdeparser.JAssignableExprcreateTransformVar(List<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 StringgetUniqueName(List<String> parameterNames, StringBuilder sb, int index) private StringgetUniqueName(List<String> parameterNames, Parameter parameter, String suffix) Methods inherited from class ClassModel
addMessageMethod, addMessageMethod, createLocaleGetter, createReadResolveMethod, generateAndWrite, generateModel, messageInterface, qualifiedClassName
-
Field Details
-
messageFormatMethodGenerated
-
copyStackTraceMethodGenerated
-
stringType
-
-
Constructor Details
-
ImplementationClassModel
ImplementationClassModel(ProcessingEnvironment processingEnv, MessageInterface messageInterface) Class constructor.- Parameters:
processingEnv- the processing environmentmessageInterface- the message interface to implement.
-
-
Method Details
-
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
-
createTransformVar
-
getUniqueName
-
getUniqueName
-
addMethodTypeParameters
-
createReturnType
private org.jboss.jdeparser.JExpr createReturnType(org.jboss.jdeparser.JClassDef classDef, MessageMethod messageMethod, org.jboss.jdeparser.JBlock body, org.jboss.jdeparser.JCall format, Map<String, org.jboss.jdeparser.JParamDeclaration> fields, Map<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, Collection<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)
-