[jboss-jira] [JBoss JIRA] (LOGTOOL-91) Add ability to provide constant values for properties
James Perkins (JIRA)
issues at jboss.org
Thu Feb 4 19:37:00 EST 2016
[ https://issues.jboss.org/browse/LOGTOOL-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13159026#comment-13159026 ]
James Perkins edited comment on LOGTOOL-91 at 2/4/16 7:36 PM:
--------------------------------------------------------------
So something like this?
{code:java}
@Retention(CLASS)
@Target({PARAMETER, METHOD})
@Documented
public @interface Property {
/**
* The property name. If not specified, the parameter name is assumed to be the property name.
*
* @return the property name
*/
String name() default "";
boolean booleanValue() default false;
byte byteValue() default Byte.MIN_VALUE;
char charValue() default Character.MIN_VALUE;
Class<?> classValue() default Object.class;
double doubleValue() default Double.MIN_VALUE;
float floatValue() default Float.MIN_VALUE;
int intValue() default Integer.MIN_VALUE;
long longValue() default Long.MIN_VALUE;
short shortValue() default Short.MIN_VALUE;
String stringValue() default "";
}
{code}
was (Author: jamezp):
So something like this?
{code:java}
@Retention(CLASS)
@Target(PARAMETER)
@Documented
public @interface Property {
/**
* The property name. If not specified, the parameter name is assumed to be the property name.
*
* @return the property name
*/
String name() default "";
boolean booleanValue() default false;
byte byteValue() default Byte.MIN_VALUE;
char charValue() default Character.MIN_VALUE;
Class<?> classValue() default Object.class;
double doubleValue() default Double.MIN_VALUE;
float floatValue() default Float.MIN_VALUE;
int intValue() default Integer.MIN_VALUE;
long longValue() default Long.MIN_VALUE;
short shortValue() default Short.MIN_VALUE;
String stringValue() default "";
}
{code}
> Add ability to provide constant values for properties
> -----------------------------------------------------
>
> Key: LOGTOOL-91
> URL: https://issues.jboss.org/browse/LOGTOOL-91
> Project: Log Tool
> Issue Type: Feature Request
> Reporter: David Lloyd
> Assignee: James Perkins
>
> Right now I have to do this:
> {code}
> @Message(id = 28, value = "An unexpected protocol error occurred")
> XAException protocolErrorXA(@Property int errorCode);
> // ... then later ...
> throw Log.log.protocolErrorXA(XAException.XAER_RMFAIL);
> {code}
> I'd rather be able to do this:
> {code}
> @Message(id = 28, value = "An unexpected protocol error occurred")
> @Property(name = "errorCode", intValue = XAException.XAER_RMFAIL)
> XAException protocolErrorXA();
> // ... then later ...
> throw Log.log.protocolErrorXA();
> {code}
> The same annotation ({{@Property}}) could be reused by making it multi-valued (i.e. invisible wrapper annotation) and adding in defaulted {{xxxValue}} parameters (primitive types, {{Class<XX>}}, and {{String}}) which are rejected when applied directly to a method parameter.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list