use of org.apache.camel.tooling.util.srcgen.Annotation in project camel-spring-boot by apache.
the class SpringBootAutoConfigurationMojo method addAnnotation.
private void addAnnotation(Function<Class<? extends java.lang.annotation.Annotation>, Annotation> creator, java.lang.annotation.Annotation ann) {
Class<? extends java.lang.annotation.Annotation> ac = ann.annotationType();
Annotation a = creator.apply(ac);
for (java.lang.reflect.Method m : ac.getMethods()) {
if ("equals".equals(m.getName()) || "toString".equals(m.getName()) || "hashCode".equals(m.getName())) {
continue;
}
String n = m.getName();
try {
Object v = m.invoke(ann);
if (v != null) {
a.setLiteralValue(n, v.toString());
}
} catch (Exception e) {
throw new RuntimeException("Unable to retrieve annotation value " + n + " on " + ac.getName());
}
}
}
Aggregations