Object unwrapped = BeansWrapper.getDefaultInstance().unwrap((TemplateModel) list.get(0));
if (!(unwrapped instanceof EnumTypeDefinition)) {
throw new TemplateModelException("The nameForEnumConstant method must have an enum type definition as a parameter.");
}
EnumTypeDefinition typeDefinition = (EnumTypeDefinition) unwrapped;
unwrapped = BeansWrapper.getDefaultInstance().unwrap((TemplateModel) list.get(1));
if (!(unwrapped instanceof EnumConstantDeclaration)) {
throw new TemplateModelException("The nameForEnumConstant method must have an enum constant declaration as a parameter.");
}
EnumConstantDeclaration constant = (EnumConstantDeclaration) unwrapped;
String name = ObjCDeploymentModule.scrubIdentifier(typeDefinition.getName());
String simpleName = ObjCDeploymentModule.scrubIdentifier(typeDefinition.getSimpleName());
String clientName = ObjCDeploymentModule.scrubIdentifier(typeDefinition.getClientSimpleName());
String simpleNameDecap = ObjCDeploymentModule.scrubIdentifier(Introspector.decapitalize(simpleName));
String clientNameDecap = ObjCDeploymentModule.scrubIdentifier(Introspector.decapitalize(clientName));
if (name == null) {
name = "anonymous_" + clientNameDecap;
}
PackageDeclaration pckg = ((TypeDeclaration) typeDefinition).getPackage();
String packageName = pckg == null ? "" : pckg.getQualifiedName();
String packageIdentifier = this.packages2ids.containsKey(packageName) ? ObjCDeploymentModule.scrubIdentifier(this.packages2ids.get(packageName)) : ObjCDeploymentModule.scrubIdentifier(packageName);
String nsid = ObjCDeploymentModule.scrubIdentifier(namespaces2ids.get(typeDefinition.getNamespace()));
String constantName = ObjCDeploymentModule.scrubIdentifier(constant.getSimpleName());
String constantClientName = ObjCDeploymentModule.scrubIdentifier(constant.getAnnotation(ClientName.class) != null ? constant.getAnnotation(ClientName.class).value() : constantName);
return String.format(this.pattern, this.projectLabel, nsid, name, clientName, clientNameDecap, simpleName, simpleNameDecap, packageIdentifier, constantClientName, constantName);
}