public class ModelChangeAnnotationResolver implements AnnotationResolver {
@Override
public Map<String, String[]> resolveAnnotation(TreeLogger logger, JClassType source, JMethod method,
final String restMethod) throws UnableToCompleteException {
ModelChange classAnnot = getAnnotation(source, ModelChange.class);
String[] serviceDomains = null;
ModelChange methodAnnot = getAnnotation(method, ModelChange.class);
final Map<String, String[]> ret = new java.util.HashMap<String, String[]>();
if(null != getAnnotation(source, Domain.class)) {
serviceDomains = getAnnotationsAsStringArray(
getAnnotation(source, Domain.class).value());
// cachedomain annotations are resolved in any case
logger.log(TreeLogger.TRACE, "found ``Domain`` annotation with " + serviceDomains.length
+ " domains in " + source.getName());
ret.put(Domain.CACHE_DOMAIN_KEY, serviceDomains);
}
if (methodAnnot != null) {
String[] domains = null;
if (methodAnnot.domain() == null
|| methodAnnot.domain().length == 0) {
if (serviceDomains == null) {
logger.log(TreeLogger.ERROR, "found method annotation with empty domain definition in " +
source.getName() + " on method " + method.getName());
throw new UnableToCompleteException();
}
logger.log(TreeLogger.TRACE, "found ``Domain`` annotation with " + serviceDomains.length
+ " domains '" + serviceDomains + "' "
+ source.getName() + " on method " + method.getName());
domains = serviceDomains;
} else {
domains = getAnnotationsAsStringArray(methodAnnot.domain());
logger.log(TreeLogger.TRACE, "use domain from ModelChange annotation at: "
+ source.getName() + "#" + method.getName() + ": " + domains);
}
// method annotation match