use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.
the class WebMethod 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;
}
use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.
the class WebParam 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;
}
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) || isMap(declaration)) {
return "Array";
}
AdapterType adapterType = JAXBUtil.findAdapterType(declaration, this.jaxbContext);
if (adapterType != null) {
return convert(adapterType.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;
}
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 (isCollection(declaration)) {
return "NSArray";
}
AdapterType adapterType = JAXBUtil.findAdapterType(declaration, this.jaxbContext);
if (adapterType != null) {
return convert(adapterType.getAdaptingType());
}
if (declaration.getKind() == ElementKind.CLASS) {
DecoratedTypeMirror superType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(declaration.getSuperclass(), this.context.getProcessingEnvironment());
if (superType != null && superType.isInstanceOf(JAXBElement.class.getName())) {
// for client conversions, we're going to generalize subclasses of JAXBElement to JAXBElement
return convert(superType);
}
}
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;
}
use of com.webcohesion.enunciate.metadata.ClientName in project enunciate by stoicflame.
the class NameForEnumConstantMethod method exec.
public Object exec(List list) throws TemplateModelException {
if (list.size() < 1) {
throw new TemplateModelException("The nameForEnumConstant method must have an enum type definition and an enum constant declaration as parameters.");
}
Object unwrapped = FreemarkerUtil.unwrap((TemplateModel) list.get(0));
if (!(unwrapped instanceof EnumValue)) {
throw new TemplateModelException("The nameForEnumConstant method must have an enum value as a parameter.");
}
EnumValue enumValue = (EnumValue) unwrapped;
EnumTypeDefinition typeDefinition = enumValue.getTypeDefinition();
String name = ObjCXMLClientModule.scrubIdentifier(typeDefinition.getName());
String simpleName = ObjCXMLClientModule.scrubIdentifier(typeDefinition.getSimpleName().toString());
String clientName = ObjCXMLClientModule.scrubIdentifier(typeDefinition.getClientSimpleName());
String simpleNameDecap = ObjCXMLClientModule.scrubIdentifier(Introspector.decapitalize(simpleName));
String clientNameDecap = ObjCXMLClientModule.scrubIdentifier(Introspector.decapitalize(clientName));
if (name == null) {
name = "anonymous_" + clientNameDecap;
}
PackageElement pckg = typeDefinition.getPackage().getDelegate();
String packageName = pckg == null ? "" : pckg.getQualifiedName().toString();
String packageIdentifier = this.packages2ids.containsKey(packageName) ? ObjCXMLClientModule.scrubIdentifier(this.packages2ids.get(packageName)) : ObjCXMLClientModule.scrubIdentifier(packageName);
String nsid = ObjCXMLClientModule.scrubIdentifier(namespaces2ids.get(typeDefinition.getNamespace()));
String constantName = ObjCXMLClientModule.scrubIdentifier(enumValue.getSimpleName().toString());
String constantClientName = ObjCXMLClientModule.scrubIdentifier(enumValue.getAnnotation(ClientName.class) != null ? enumValue.getAnnotation(ClientName.class).value() : constantName);
return String.format(this.pattern, this.projectLabel, nsid, name, clientName, clientNameDecap, simpleName, simpleNameDecap, packageIdentifier, constantClientName, constantName);
}
Aggregations