use of org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor in project controller by opendaylight.
the class TemplateFactory method tOsFromMbe.
public static Map<String, GeneralClassTemplate> tOsFromMbe(final ModuleMXBeanEntry mbe) {
final Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
final TOAttributesProcessor processor = new TOAttributesProcessor();
processor.processAttributes(mbe.getAttributes());
for (final org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor.getTOs()) {
final List<Constructor> constructors = Lists.newArrayList();
constructors.add(new Constructor(to.getName(), "super();"));
final Header header = getHeaderFromEntry(mbe);
retVal.put(to.getType(), new GeneralClassTemplate(header, mbe.getPackageName(), to.getName(), Collections.<String>emptyList(), Collections.<String>emptyList(), to.getFields(), to.getMethods(), false, false, constructors));
}
return retVal;
}
use of org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor in project controller by opendaylight.
the class TemplateFactory method tOsFromRbe.
public static Map<String, GeneralClassTemplate> tOsFromRbe(final RuntimeBeanEntry rbe) {
final Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
final TOAttributesProcessor processor = new TOAttributesProcessor();
final Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
// Add TOs from output parameters
for (final Rpc rpc : rbe.getRpcs()) {
final AttributeIfc returnType = rpc.getReturnType();
if (returnType == VoidAttribute.getInstance()) {
continue;
}
if (returnType instanceof JavaAttribute) {
continue;
}
if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType) {
continue;
}
Preconditions.checkState(!yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()), "Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
yangPropertiesToTypesMap.put(returnType.getAttributeYangName(), returnType);
}
processor.processAttributes(yangPropertiesToTypesMap);
for (final org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor.getTOs()) {
final List<Constructor> constructors = Lists.newArrayList();
constructors.add(new Constructor(to.getName(), "super();"));
// TODO header
retVal.put(to.getType(), new GeneralClassTemplate(null, rbe.getPackageName(), to.getName(), Collections.<String>emptyList(), Collections.<String>emptyList(), to.getFields(), to.getMethods(), false, false, constructors));
}
return retVal;
}
use of org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor in project controller by opendaylight.
the class GenericGeneratedObjectFactory method toGeneratedObject.
public GeneratedObject toGeneratedObject(FtlTemplate template, Optional<String> copyright) {
JavaFileInputBuilder b = new JavaFileInputBuilder();
b.setHeader(template.getHeaderString());
b.setFqn(new FullyQualifiedName(template.getPackageName(), template.getTypeDeclaration().getName()));
b.setClassJavaDoc(template.getMaybeJavadoc());
for (Annotation annotation : template.getAnnotations()) {
b.addClassAnnotation(annotation);
}
// type declaration
for (String extended : template.getTypeDeclaration().getExtended()) {
b.addExtendsFQN(FullyQualifiedName.fromString(extended));
}
for (String implemented : template.getTypeDeclaration().getImplemented()) {
b.addImplementsFQN(FullyQualifiedName.fromString(implemented));
}
b.setCopyright(copyright);
b.setTypeName(template.getTypeDeclaration().toTypeName());
// fields
for (Field field : template.getFields()) {
b.addToBody(field.toString());
}
// constructors
for (Constructor constructor : template.getConstructors()) {
b.addToBody(constructor.toString());
}
// methods
for (Method method : template.getMethods()) {
b.addToBody(method.toString());
}
return new GeneratedObjectBuilder(b.build()).toGeneratedObject();
}
Aggregations