To summarize my goal:
- I don't want a central place where I have to summarize all tokenizers in my application.
E.g. When I add a new place and an appropriate tokenizer I HAVE to specifiy the tokenizer using the @WithTokenizers annotation
- Later I would also like to remove the "instanceof" boilterplate from my ActivityMappers (using a generator)
Imo one solution would be to create a custom generator (similar to gwt's PlaceHistoryMapperGenerator) as follows:
- I can add some custom annotation lets say @AppTokenizer and annotate every implementation of PlaceTokenizer in my app
- The generator can than create a class which resolves all PlaceTokenizers with that annotation
my concern is that: in order to find all PlaceTokenizer if have to to something like this in my generator:
JClassType[] types = typeOracle.getTypes();
for (JClassType type : types) {
if (type.getAnnotation(SomeAnnotation.class) != null) {
//some more stuff here
}
}
So the generator loops through *all* available types to find the appropriate tokenizers to be used.
This may be slow - is this the reason why we have to summarize all Tokenizers (Using @WithTokenizer annotation) in the gwt standard approach?
Are there any better ways to achieve such functionality?
tia,
daniel