Search in sources :

Example 6 with ClientName

use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.

the class TypeNameForMethod method convert.

@Override
public String convert(TypeElement declaration) throws TemplateModelException {
    String fqn = declaration.getQualifiedName().toString();
    if (classConversions.containsKey(fqn)) {
        return classConversions.get(fqn);
    } else if (declaration.getKind() == ElementKind.ENUM) {
        return "string";
    } else if (isCollection(declaration) || isStream(declaration) || isMap(declaration)) {
        return "array";
    }
    if (this.jacksonContext != null) {
        AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext);
        if (adapterType != null) {
            return convert(adapterType.getAdaptingType());
        }
    }
    if (this.jackson1Context != null) {
        com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType adapter1Type = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context);
        if (adapter1Type != null) {
            return convert(adapter1Type.getAdaptingType());
        }
    }
    String convertedPackage = convertPackage(this.context.getProcessingEnvironment().getElementUtils().getPackageOf(declaration));
    ClientName specifiedName = declaration.getAnnotation(ClientName.class);
    String simpleName = specifiedName == null ? declaration.getSimpleName().toString() : specifiedName.value();
    return convertedPackage + getPackageSeparator() + simpleName;
}
Also used : ClientName(com.webcohesion.enunciate.metadata.ClientName) AdapterType(com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)

Example 7 with ClientName

use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.

the class ClientClassnameForMethod method convert.

@Override
public String convert(TypeElement declaration) throws TemplateModelException {
    String fqn = declaration.getQualifiedName().toString();
    if (classConversions.containsKey(fqn)) {
        return classConversions.get(fqn);
    } else if (declaration.getKind() == ElementKind.ENUM) {
        return "String";
    } else if (isCollection(declaration) || isStream(declaration) || isMap(declaration)) {
        return "Array";
    }
    if (this.jacksonContext != null) {
        AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext);
        if (adapterType != null) {
            return convert(adapterType.getAdaptingType());
        }
    }
    if (this.jackson1Context != null) {
        com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType adapter1Type = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context);
        if (adapter1Type != null) {
            return convert(adapter1Type.getAdaptingType());
        }
    }
    String convertedPackage = convertPackage(this.context.getProcessingEnvironment().getElementUtils().getPackageOf(declaration));
    ClientName specifiedName = declaration.getAnnotation(ClientName.class);
    String simpleName = specifiedName == null ? declaration.getSimpleName().toString() : specifiedName.value();
    return convertedPackage + getPackageSeparator() + simpleName;
}
Also used : ClientName(com.webcohesion.enunciate.metadata.ClientName) AdapterType(com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)

Example 8 with ClientName

use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.

the class AnyElement method getClientSimpleName.

/**
 * The simple name for client-side code generation.
 *
 * @return The simple name for client-side code generation.
 */
public String getClientSimpleName() {
    String clientSimpleName = getSimpleName().toString();
    ClientName clientName = getAnnotation(ClientName.class);
    if (clientName != null) {
        clientSimpleName = clientName.value();
    }
    return clientSimpleName;
}
Also used : ClientName(com.webcohesion.enunciate.metadata.ClientName)

Example 9 with ClientName

use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.

the class ClientClassnameForMethod method convert.

@Override
public String convert(TypeElement declaration) throws TemplateModelException {
    String fqn = declaration.getQualifiedName().toString();
    if (classConversions.containsKey(fqn)) {
        return classConversions.get(fqn);
    } else if (declaration.getKind() == ElementKind.ENUM) {
        return "String";
    } else if (isCollection(declaration) || isStream(declaration) || isMap(declaration)) {
        return "Array";
    }
    if (this.jacksonContext != null) {
        AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext);
        if (adapterType != null) {
            return convert(adapterType.getAdaptingType());
        }
    }
    if (this.jackson1Context != null) {
        com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType adapter1Type = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context);
        if (adapter1Type != null) {
            return convert(adapter1Type.getAdaptingType());
        }
    }
    String convertedPackage = convertPackage(this.context.getProcessingEnvironment().getElementUtils().getPackageOf(declaration));
    ClientName specifiedName = declaration.getAnnotation(ClientName.class);
    String simpleName = specifiedName == null ? declaration.getSimpleName().toString() : specifiedName.value();
    return convertedPackage + getPackageSeparator() + simpleName;
}
Also used : ClientName(com.webcohesion.enunciate.metadata.ClientName) AdapterType(com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)

Example 10 with ClientName

use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.

the class TypeNameForMethod method convert.

@Override
public String convert(TypeElement declaration) throws TemplateModelException {
    String fqn = declaration.getQualifiedName().toString();
    if (classConversions.containsKey(fqn)) {
        return classConversions.get(fqn);
    } else if (declaration.getKind() == ElementKind.ENUM) {
        return "string";
    } else if (isCollection(declaration) || isStream(declaration) || isMap(declaration)) {
        return "array";
    }
    if (this.jacksonContext != null) {
        AdapterType adapterType = JacksonUtil.findAdapterType(declaration, this.jacksonContext);
        if (adapterType != null) {
            return convert(adapterType.getAdaptingType());
        }
    }
    if (this.jackson1Context != null) {
        com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType adapter1Type = com.webcohesion.enunciate.modules.jackson1.model.util.JacksonUtil.findAdapterType(declaration, this.jackson1Context);
        if (adapter1Type != null) {
            return convert(adapter1Type.getAdaptingType());
        }
    }
    String convertedPackage = convertPackage(this.context.getProcessingEnvironment().getElementUtils().getPackageOf(declaration));
    ClientName specifiedName = declaration.getAnnotation(ClientName.class);
    String simpleName = specifiedName == null ? declaration.getSimpleName().toString() : specifiedName.value();
    return "\\" + convertedPackage + getPackageSeparator() + simpleName;
}
Also used : ClientName(com.webcohesion.enunciate.metadata.ClientName) AdapterType(com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)

Aggregations

ClientName (com.webcohesion.enunciate.metadata.ClientName)31 DecoratedTypeMirror (com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror)7 AdapterType (com.webcohesion.enunciate.modules.jaxb.model.adapters.AdapterType)6 AdapterType (com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)5 EnumTypeDefinition (com.webcohesion.enunciate.modules.jaxb.model.EnumTypeDefinition)2 EnumValue (com.webcohesion.enunciate.modules.jaxb.model.EnumValue)2 TemplateModelException (freemarker.template.TemplateModelException)2 PackageElement (javax.lang.model.element.PackageElement)2 TypeMirror (javax.lang.model.type.TypeMirror)2 com.webcohesion.enunciate.modules.jaxb.model (com.webcohesion.enunciate.modules.jaxb.model)1 MapType (com.webcohesion.enunciate.modules.jaxb.model.util.MapType)1 EndpointInterface (com.webcohesion.enunciate.modules.jaxws.model.EndpointInterface)1 WebMethod (com.webcohesion.enunciate.modules.jaxws.model.WebMethod)1 WebParam (com.webcohesion.enunciate.modules.jaxws.model.WebParam)1 VariableElement (javax.lang.model.element.VariableElement)1