annotations
annotations copied to clipboard
Add method getAsString
Currently there is a method AnnotationBag::getAsArray()
That's very convenient when we want to make sure to retrieve an array.
What's about adding a method
AnnotationBag::getAsString()
or AnnotationBag::getAsRawString()
to get the annotation value as a string. Even if it's in array or object annotation,
we sometime want to get this value as the raw original string.
We could do that by changing the parser. But sometime we can need both of the ouput depending on the annotation name.
What's your opinion ?
It will depend on how much change it would require on public classes.
And what's about publishing it for v3 ?
For v3 it would be ok as long as it's not a huge BC break on the AnnotationsBag public API, which I believe is perfectly possible to do with internal changes only.
That would actually require to change the constructor
and the set
methods of the annotation bag, because we need to pass both of the original string and the parsed one.
An other approach would be to pass only the raw string, and the annotationBag
would be responsible to transform the raw string into the good type