Package org.jboss.logging.processor.apt
Class MessageMethodBuilder.AptMessageMethod
- java.lang.Object
-
- org.jboss.logging.processor.apt.MessageMethodBuilder.AptMessageMethod
-
- All Implemented Interfaces:
java.lang.Comparable<MessageMethod>
,javax.lang.model.AnnotatedConstruct
,javax.lang.model.element.Element
,javax.lang.model.element.ExecutableElement
,javax.lang.model.element.Parameterizable
,DelegatingElement
,DelegatingExecutableElement
,JavaDocComment
,MessageMethod
- Enclosing class:
- MessageMethodBuilder
private static class MessageMethodBuilder.AptMessageMethod extends java.lang.Object implements MessageMethod
An implementation for the MessageMethod interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.logging.processor.model.MessageMethod
MessageMethod.Message
-
-
Field Summary
Fields Modifier and Type Field Description private Parameter
cause
private javax.lang.model.util.Elements
elements
private int
formatParameterCount
private boolean
inheritsMessage
private boolean
isOverloaded
private MessageMethod.Message
message
private java.lang.String
messageMethodName
private javax.lang.model.element.ExecutableElement
method
private java.util.Map<javax.lang.model.type.TypeMirror,java.util.Set<Parameter>>
parameters
private ReturnType
returnType
private java.util.Set<ThrowableType>
thrownTypes
private java.lang.String
translationKey
-
Constructor Summary
Constructors Constructor Description AptMessageMethod(javax.lang.model.util.Elements elements, javax.lang.model.element.ExecutableElement method)
Private constructor for the
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
add(Parameter parameter)
Parameter
cause()
int
compareTo(MessageMethod o)
boolean
equals(java.lang.Object obj)
int
formatParameterCount()
Returns the number of parameters minus the cause parameter count for the method.java.lang.String
getComment()
The JavaDoc comments if available ornull
if there are no JavaDoc's present.javax.lang.model.element.ExecutableElement
getDelegate()
The element to delegate the default methods to.boolean
hasCause()
Returnstrue
if there is a cause element, otherwisefalse
.int
hashCode()
boolean
inheritsMessage()
Indicates whether the message was inherited from another message or not.boolean
isLoggerMethod()
Returnstrue
if this is a logger method, otherwisefalse
.boolean
isOverloaded()
Returnstrue
if the method is overloaded, otherwisefalse
.java.lang.String
loggerMethod()
Returns the LogMessage annotation associated with this method only ifMessageMethod.isLoggerMethod()
returnstrue
.java.lang.String
logLevel()
Returns the log level parameter associated with the method only ifMessageMethod.isLoggerMethod()
returnstrue
.MessageMethod.Message
message()
TheMessageMethod.Message
to be used for the method.java.lang.String
messageMethodName()
Returns the name of the method used to retrieve the message.java.lang.String
name()
Returns the method name.java.util.Set<Parameter>
parameters()
Returns the parameters for the method.java.util.Set<Parameter>
parametersAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Returns an unmodifiable collection of the parameters specified by the parameter type or an empty set.ReturnType
returnType()
Returns the return type for the method.java.util.Set<ThrowableType>
thrownTypes()
Returns a collection of throwable types the method throws.java.lang.String
toString()
java.lang.String
translationKey()
Returns the name of the key used in the translation files for the message translation.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.logging.processor.model.DelegatingElement
accept, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getEnclosedElements, getEnclosingElement, getKind, getModifiers, isAnnotatedWith
-
Methods inherited from interface org.jboss.logging.processor.model.DelegatingExecutableElement
asType, getDefaultValue, getParameters, getReceiverType, getReturnType, getSimpleName, getThrownTypes, getTypeParameters, isDefault, isVarArgs
-
-
-
-
Field Detail
-
elements
private final javax.lang.model.util.Elements elements
-
parameters
private final java.util.Map<javax.lang.model.type.TypeMirror,java.util.Set<Parameter>> parameters
-
thrownTypes
private final java.util.Set<ThrowableType> thrownTypes
-
method
private final javax.lang.model.element.ExecutableElement method
-
returnType
private ReturnType returnType
-
cause
private Parameter cause
-
inheritsMessage
private boolean inheritsMessage
-
isOverloaded
private boolean isOverloaded
-
message
private MessageMethod.Message message
-
messageMethodName
private java.lang.String messageMethodName
-
translationKey
private java.lang.String translationKey
-
formatParameterCount
private int formatParameterCount
-
-
Method Detail
-
add
void add(Parameter parameter)
-
name
public java.lang.String name()
Description copied from interface:MessageMethod
Returns the method name.- Specified by:
name
in interfaceMessageMethod
- Returns:
- the method name.
-
parameters
public java.util.Set<Parameter> parameters()
Description copied from interface:MessageMethod
Returns the parameters for the method.- Specified by:
parameters
in interfaceMessageMethod
- Returns:
- the parameters for the method
-
parametersAnnotatedWith
public java.util.Set<Parameter> parametersAnnotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Description copied from interface:MessageMethod
Returns an unmodifiable collection of the parameters specified by the parameter type or an empty set.- Specified by:
parametersAnnotatedWith
in interfaceMessageMethod
- Parameters:
annotation
- the annotation to get the parameters for- Returns:
- a collection of the parameters or an empty set.
-
returnType
public ReturnType returnType()
Description copied from interface:MessageMethod
Returns the return type for the method.- Specified by:
returnType
in interfaceMessageMethod
- Returns:
- the return type for the method.
-
thrownTypes
public java.util.Set<ThrowableType> thrownTypes()
Description copied from interface:MessageMethod
Returns a collection of throwable types the method throws. If the method throws no exceptions an empty collection is returned.- Specified by:
thrownTypes
in interfaceMessageMethod
- Returns:
- a collection of throwable types or an empty collection.
-
message
public MessageMethod.Message message()
Description copied from interface:MessageMethod
TheMessageMethod.Message
to be used for the method.- Specified by:
message
in interfaceMessageMethod
- Returns:
- the message.
-
inheritsMessage
public boolean inheritsMessage()
Description copied from interface:MessageMethod
Indicates whether the message was inherited from another message or not. Iftrue
is returned theMessageMethod.Message
was inherited from a different method, otherwisefalse
. Note:false
does not indicate the method has aMessage
annotation.- Specified by:
inheritsMessage
in interfaceMessageMethod
- Returns:
true
if the message was inherited from a different method, otherwisefalse
.
-
messageMethodName
public java.lang.String messageMethodName()
Description copied from interface:MessageMethod
Returns the name of the method used to retrieve the message.- Specified by:
messageMethodName
in interfaceMessageMethod
- Returns:
- the name of the message method.
-
translationKey
public java.lang.String translationKey()
Description copied from interface:MessageMethod
Returns the name of the key used in the translation files for the message translation.- Specified by:
translationKey
in interfaceMessageMethod
- Returns:
- the name of the key in the translation files.
-
hasCause
public boolean hasCause()
Description copied from interface:MessageMethod
Returnstrue
if there is a cause element, otherwisefalse
.- Specified by:
hasCause
in interfaceMessageMethod
- Returns:
true
if there is a cause element, otherwisefalse
-
isOverloaded
public boolean isOverloaded()
Description copied from interface:MessageMethod
Returnstrue
if the method is overloaded, otherwisefalse
.- Specified by:
isOverloaded
in interfaceMessageMethod
- Returns:
true
if the method is overloaded, otherwisefalse
-
cause
public Parameter cause()
Description copied from interface:MessageMethod
- Specified by:
cause
in interfaceMessageMethod
- Returns:
- the cause element, otherwise
null
.
-
loggerMethod
public java.lang.String loggerMethod()
Description copied from interface:MessageMethod
Returns the LogMessage annotation associated with this method only ifMessageMethod.isLoggerMethod()
returnstrue
.- Specified by:
loggerMethod
in interfaceMessageMethod
- Returns:
- the log message annotation
-
logLevel
public java.lang.String logLevel()
Description copied from interface:MessageMethod
Returns the log level parameter associated with the method only ifMessageMethod.isLoggerMethod()
returnstrue
.- Specified by:
logLevel
in interfaceMessageMethod
- Returns:
- the enum name of the log level
-
formatParameterCount
public int formatParameterCount()
Description copied from interface:MessageMethod
Returns the number of parameters minus the cause parameter count for the method.- Specified by:
formatParameterCount
in interfaceMessageMethod
- Returns:
- the number of parameters minus the cause parameter count for the method.
-
isLoggerMethod
public boolean isLoggerMethod()
Description copied from interface:MessageMethod
Returnstrue
if this is a logger method, otherwisefalse
.- Specified by:
isLoggerMethod
in interfaceMessageMethod
- Returns:
true
if this is a logger method, otherwisefalse
.
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejavax.lang.model.element.Element
- Overrides:
hashCode
in classjava.lang.Object
-
getDelegate
public javax.lang.model.element.ExecutableElement getDelegate()
Description copied from interface:DelegatingElement
The element to delegate the default methods to.- Specified by:
getDelegate
in interfaceDelegatingElement
- Specified by:
getDelegate
in interfaceDelegatingExecutableElement
- Returns:
- the delegate
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejavax.lang.model.element.Element
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(MessageMethod o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<MessageMethod>
-
getComment
public java.lang.String getComment()
Description copied from interface:JavaDocComment
The JavaDoc comments if available ornull
if there are no JavaDoc's present.- Specified by:
getComment
in interfaceJavaDocComment
- Returns:
- the JavaDoc comments or
null
.
-
-