[jboss-jira] [JBoss JIRA] (LOGTOOL-55) Introduce "transformation" annotations

James Perkins (JIRA) jira-events at lists.jboss.org
Tue Oct 30 17:18:01 EDT 2012


    [ https://issues.jboss.org/browse/LOGTOOL-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730225#comment-12730225 ] 

James Perkins commented on LOGTOOL-55:
--------------------------------------

Pull request https://github.com/jboss-logging/jboss-logging-tools/pull/7
                
> Introduce "transformation" annotations
> --------------------------------------
>
>                 Key: LOGTOOL-55
>                 URL: https://issues.jboss.org/browse/LOGTOOL-55
>             Project: Log Tool
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>            Reporter: David Lloyd
>            Assignee: David Lloyd
>            Priority: Optional
>
> It would be nice to be able to introduce transformations which are applied to method parameters, like this:
> {code}
> @Message(id = 1234, value = "This is a bad %s")
> IllegalStateException badType(@Transform(GET_CLASS) Object thing);
> {code}
> ...where {{GET_CLASS}} comes from an enum of predefined transformations.  The resultant code would replace {{thing}} in the final rendering with {{thing == null ? null : thing.getClass()}}.
> It might make sense to support multiple transforms too:
> {code}
> @Message(value = "The class' hash is %x")
> String hashWoo(@Transform({GET_CLASS, HASH_CODE}) Object thing);
> {code}
> in which case the transforms would be applied in order from left to right.  Some transform ideas:
> * {{GET_CLASS}} -> {{x == null ? null : x.getClass()}}
> * {{HASH_CODE}} -> {{x == null ? 0 : x.hashCode()}}
> * {{IDENTITY_HASH_CODE}} -> {{x == null ? 0 : System.identityHashCode( x )}}
> * {{SIZE}} -> depending on type, choose String.length(), array.length, Collection/Map.size()
> In the generated comments, the parameter descriptions should include the transformations applied (in English order i.e. right to left, opposite of the enum list order on the annotation):
> {code}
> // parameter 1 - thing
> // parameter 2 - class of thing
> // parameter 3 - hashCode of class of thing
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list