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

David Lloyd (JIRA) jira-events at lists.jboss.org
Tue Sep 11 18:37:32 EDT 2012


David Lloyd created LOGTOOL-55:
----------------------------------

             Summary: 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.  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()


--
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