use of org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDeclaration in project controller by opendaylight.
the class TemplateFactory method getTOAndMXInterfaceFtlFiles.
/**
* Get map of file name as key, FtlFile instance representing runtime mx
* bean as value that should be persisted from this instance.
*/
public static Map<String, FtlTemplate> getTOAndMXInterfaceFtlFiles(final RuntimeBeanEntry entry) {
final Map<String, FtlTemplate> result = new HashMap<>();
{
// create GeneralInterfaceFtlFile for runtime MXBean. Attributes will
// be transformed to getter methods
final String mxBeanTypeName = entry.getJavaNameOfRuntimeMXBean();
final List<String> extendedInterfaces = Collections.singletonList(RuntimeBean.class.getCanonicalName());
final List<MethodDeclaration> methods = new ArrayList<>();
// convert attributes to getters
for (final AttributeIfc attributeIfc : entry.getAttributes()) {
String returnType;
returnType = getReturnType(attributeIfc);
final String getterName = "get" + attributeIfc.getUpperCaseCammelCase();
final MethodDeclaration getter = new MethodDeclaration(returnType, getterName, Collections.<Field>emptyList());
methods.add(getter);
}
// add rpc methods
for (final Rpc rpc : entry.getRpcs()) {
// convert JavaAttribute parameters into fields
final List<Field> fields = new ArrayList<>();
for (final JavaAttribute ja : rpc.getParameters()) {
final Field field = new Field(Collections.emptyList(), ja.getType().getFullyQualifiedName(), ja.getLowerCaseCammelCase(), ja.getNullableDefaultWrappedForCode());
fields.add(field);
}
final MethodDeclaration operation = new MethodDeclaration(getReturnType(rpc.getReturnType()), rpc.getName(), fields);
methods.add(operation);
}
// FIXME header
final GeneralInterfaceTemplate runtimeMxBeanIfc = new GeneralInterfaceTemplate(null, entry.getPackageName(), mxBeanTypeName, extendedInterfaces, methods);
result.put(runtimeMxBeanIfc.getTypeDeclaration().getName() + ".java", runtimeMxBeanIfc);
}
result.putAll(TemplateFactory.tOsFromRbe(entry));
return result;
}
Aggregations