Search in sources :

Example 1 with DecoratedAnnotationMirror

use of com.webcohesion.enunciate.javac.decorations.element.DecoratedAnnotationMirror in project enunciate by stoicflame.

the class AnnotationValueMethod method exec.

/**
 * Returns the qname of the element that has the first parameter as the namespace, the second as the element.
 *
 * @param list The arguments.
 * @return The qname.
 */
public Object exec(List list) throws TemplateModelException {
    if (list.size() < 1) {
        throw new TemplateModelException("The annotationValue method must have a declaration as a parameter.");
    }
    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = DeepUnwrap.unwrap(from);
    String method = "value";
    if (list.size() > 1) {
        method = (String) DeepUnwrap.unwrap((TemplateModel) list.get(1));
    }
    if (unwrapped instanceof DecoratedAnnotationMirror) {
        return invoke(method, ((DecoratedAnnotationMirror) unwrapped));
    }
    throw new EnunciateException(String.format("Unsupported method %s on %s", method, unwrapped));
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) DecoratedAnnotationMirror(com.webcohesion.enunciate.javac.decorations.element.DecoratedAnnotationMirror) EnunciateException(com.webcohesion.enunciate.EnunciateException) TemplateModel(freemarker.template.TemplateModel)

Aggregations

EnunciateException (com.webcohesion.enunciate.EnunciateException)1 DecoratedAnnotationMirror (com.webcohesion.enunciate.javac.decorations.element.DecoratedAnnotationMirror)1 TemplateModel (freemarker.template.TemplateModel)1 TemplateModelException (freemarker.template.TemplateModelException)1