Search in sources :

Example 1 with AnyElement

use of com.webcohesion.enunciate.modules.jaxb.model.AnyElement in project enunciate by stoicflame.

the class ClientSimpleNameMethod method exec.

public Object exec(List list) throws TemplateModelException {
    if (list.size() < 1) {
        throw new TemplateModelException("The functionIdentifierFor method must have an accessor or type mirror as a parameter.");
    }
    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    String name;
    if (unwrapped instanceof Accessor) {
        Accessor accessor = (Accessor) unwrapped;
        name = accessor.getClientSimpleName();
        if (this.clientNames.containsKey(name)) {
            name = this.clientNames.get(name);
        }
    } else if (unwrapped instanceof AnyElement) {
        AnyElement accessor = (AnyElement) unwrapped;
        name = accessor.getClientSimpleName();
        if (this.clientNames.containsKey(name)) {
            name = this.clientNames.get(name);
        }
    } else {
        throw new TemplateModelException("The clientSimpleName method must have an accessor as a parameter.");
    }
    return name;
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) AnyElement(com.webcohesion.enunciate.modules.jaxb.model.AnyElement) TemplateModel(freemarker.template.TemplateModel) Accessor(com.webcohesion.enunciate.modules.jaxb.model.Accessor)

Aggregations

Accessor (com.webcohesion.enunciate.modules.jaxb.model.Accessor)1 AnyElement (com.webcohesion.enunciate.modules.jaxb.model.AnyElement)1 TemplateModel (freemarker.template.TemplateModel)1 TemplateModelException (freemarker.template.TemplateModelException)1