use of com.webcohesion.enunciate.modules.jaxb.model.EnumValue 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 = CXMLClientModule.scrubIdentifier(typeDefinition.getName());
String simpleName = CXMLClientModule.scrubIdentifier(typeDefinition.getSimpleName().toString());
String clientName = CXMLClientModule.scrubIdentifier(typeDefinition.getClientSimpleName());
String simpleNameDecap = CXMLClientModule.scrubIdentifier(Introspector.decapitalize(simpleName));
String clientNameDecap = CXMLClientModule.scrubIdentifier(Introspector.decapitalize(clientName));
if (name == null) {
name = "anonymous_" + clientNameDecap;
}
PackageElement pckg = typeDefinition.getPackage().getDelegate();
String packageUnderscored = CXMLClientModule.scrubIdentifier(pckg != null ? pckg.getQualifiedName().toString().replace('.', '_') : "");
String nsid = CXMLClientModule.scrubIdentifier(namespaces2ids.get(typeDefinition.getNamespace()));
String constantName = CXMLClientModule.scrubIdentifier(enumValue.getSimpleName().toString());
String constantClientName = CXMLClientModule.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, packageUnderscored, constantClientName, constantName);
}
use of com.webcohesion.enunciate.modules.jaxb.model.EnumValue 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);
}
use of com.webcohesion.enunciate.modules.jaxb.model.EnumValue in project enunciate by stoicflame.
the class EnumDataTypeImpl method getValues.
@Override
public List<? extends Value> getValues() {
FacetFilter facetFilter = this.registrationContext.getFacetFilter();
List<EnumValue> enumValues = this.typeDefinition.getEnumValues();
ArrayList<Value> values = new ArrayList<Value>(enumValues.size());
for (EnumValue enumValue : enumValues) {
if (enumValue.getValue() != null) {
if (!facetFilter.accept(enumValue)) {
continue;
}
values.add(createValue(enumValue));
}
}
return values;
}
Aggregations