Search in sources :

Example 1 with Annotation

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());
        }
    }
}
Also used : Annotation(org.apache.camel.tooling.util.srcgen.Annotation) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

IOException (java.io.IOException)1 Annotation (org.apache.camel.tooling.util.srcgen.Annotation)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1