import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.management.openmbean.SimpleType;
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.IdentityAttributeRef;
import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
import org.opendaylight.controller.config.api.runtime.RuntimeBean;
-import org.opendaylight.controller.config.spi.Module;
+import org.opendaylight.controller.config.spi.AbstractModule;
import org.opendaylight.controller.config.yangjmxgenerator.AbstractEntry;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import javax.management.openmbean.SimpleType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
public class TemplateFactory {
/**
static String serializeType(Type type, boolean addWildcards) {
if (type instanceof ParameterizedType){
ParameterizedType parameterizedType = (ParameterizedType) type;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append(parameterizedType.getRawType().getFullyQualifiedName());
sb.append(addWildcards ? "<? extends " : "<");
boolean first = true;
Lists.<MethodDeclaration> newArrayList());
sieTemplate.setJavadoc(sie.getNullableDescription());
- if (sie.getNullableDescription() != null)
+ if (sie.getNullableDescription() != null) {
sieTemplate.getAnnotations().add(
Annotation.createDescriptionAnnotation(sie
.getNullableDescription()));
+ }
sieTemplate.getAnnotations().addAll(Annotation.createSieAnnotations(sie));
return sieTemplate;
List<ModuleField> moduleFields = attrProcessor.getModuleFields();
List<String> implementedIfcs = Lists.newArrayList(
- Module.class.getCanonicalName(),
mbe.getFullyQualifiedName(mbe.getMXBeanInterfaceName()));
for (String implementedService : mbe.getProvidedServices().keySet()) {
.getCanonicalName());
}
+ List<String> extendedClasses = Collections.singletonList(AbstractModule.class.getCanonicalName() + "<" + mbe.getAbstractModuleName() + ">");
+
AbstractModuleTemplate abstractModuleTemplate = new AbstractModuleTemplate(
getHeaderFromEntry(mbe), mbe.getPackageName(),
- mbe.getAbstractModuleName(), implementedIfcs, moduleFields,
+ mbe.getAbstractModuleName(), extendedClasses, implementedIfcs, moduleFields,
attrProcessor.getMethods(), generateRuntime,
registratorFullyQualifiedName);
- if (mbe.getNullableDescription() != null)
+ if (mbe.getNullableDescription() != null) {
abstractModuleTemplate.getAnnotations().add(
Annotation.createDescriptionAnnotation(mbe
.getNullableDescription()));
+ }
return abstractModuleTemplate;
}
for (Rpc rpc : rbe.getRpcs()) {
AttributeIfc returnType = rpc.getReturnType();
- if (returnType == VoidAttribute.getInstance())
+ if (returnType == VoidAttribute.getInstance()) {
continue;
- if (returnType instanceof JavaAttribute)
+ }
+ if (returnType instanceof JavaAttribute) {
continue;
- if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType)
+ }
+ if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType) {
continue;
+ }
Preconditions.checkState(yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()) == false,
"Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
String returnType;
AttributeIfc attributeIfc = attrEntry.getValue();
- boolean isIdentityRef = false;
if (attributeIfc instanceof TypedAttribute) {
TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
returnType = serializeType(typedAttribute.getType());
String varName = BindingGeneratorUtil
.parseToValidParamName(attrEntry.getKey());
- {
- ModuleField field;
+ ModuleField field;
if (isIdentity) {
String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
nullableDefaultWrapped, isDependency, dependency, isListOfDependencies, needsDepResolver);
}
moduleFields.add(field);
- }
+
+
String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
MethodDefinition getter = new MethodDefinition(type,
private static boolean needsDepResolver(AttributeIfc value) {
- if(value instanceof TOAttribute)
+ if(value instanceof TOAttribute) {
return true;
+ }
if(value instanceof ListAttribute) {
AttributeIfc innerAttribute = ((ListAttribute) value).getInnerAttribute();
return needsDepResolver(innerAttribute);