-
Feature Request
-
Resolution: Done
-
Optional
-
None
-
None
It would be nice to be able to introduce transformations which are applied to method parameters, like this:
@Message(id = 1234, value = "This is a bad %s") IllegalStateException badType(@Transform(GET_CLASS) Object thing);
...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:
@Message(value = "The class' hash is %x") String hashWoo(@Transform({GET_CLASS, HASH_CODE}) Object thing);
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):
// parameter 1 - thing // parameter 2 - class of thing // parameter 3 - hashCode of class of thing