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.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.yangtools.yang.binding.BindingMapping;
public class TemplateFactory {
* bean as value that should be persisted from this instance.
*/
public static Map<String, FtlTemplate> getTOAndMXInterfaceFtlFiles(
- RuntimeBeanEntry entry) {
+ final RuntimeBeanEntry entry) {
Map<String, FtlTemplate> result = new HashMap<>();
{ // create GeneralInterfaceFtlFile for runtime MXBean. Attributes will
// be transformed to getter methods
}
// FIXME: put into Type.toString
- static String serializeType(Type type, boolean addWildcards) {
+ static String serializeType(final Type type, final boolean addWildcards) {
if (type instanceof ParameterizedType){
ParameterizedType parameterizedType = (ParameterizedType) type;
StringBuilder sb = new StringBuilder();
}
}
- static String serializeType(Type type) {
+ static String serializeType(final Type type) {
return serializeType(type, false);
}
- private static String getReturnType(AttributeIfc attributeIfc) {
+ private static String getReturnType(final AttributeIfc attributeIfc) {
String returnType;
if (attributeIfc instanceof TypedAttribute) {
Type type = ((TypedAttribute) attributeIfc).getType();
}
public static GeneralInterfaceTemplate serviceInterfaceFromSie(
- ServiceInterfaceEntry sie) {
+ final ServiceInterfaceEntry sie) {
List<String> extendedInterfaces = Lists
.newArrayList(AbstractServiceInterface.class.getCanonicalName());
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;
}
public static AbstractFactoryTemplate abstractFactoryTemplateFromMbe(
- ModuleMXBeanEntry mbe) {
+ final ModuleMXBeanEntry mbe) {
AbstractFactoryAttributesProcessor attrProcessor = new AbstractFactoryAttributesProcessor();
attrProcessor.processAttributes(mbe.getAttributes(),
mbe.getPackageName());
}
public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
- ModuleMXBeanEntry mbe) {
+ final ModuleMXBeanEntry mbe) {
AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor(mbe.getAttributes());
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;
}
public static StubFactoryTemplate stubFactoryTemplateFromMbe(
- ModuleMXBeanEntry mbe) {
+ final ModuleMXBeanEntry mbe) {
return new StubFactoryTemplate(getHeaderFromEntry(mbe),
mbe.getPackageName(), mbe.getStubFactoryName(),
mbe.getFullyQualifiedName(mbe.getAbstractFactoryName())
}
public static GeneralInterfaceTemplate mXBeanInterfaceTemplateFromMbe(
- ModuleMXBeanEntry mbe) {
+ final ModuleMXBeanEntry mbe) {
MXBeanInterfaceAttributesProcessor attrProcessor = new MXBeanInterfaceAttributesProcessor();
attrProcessor.processAttributes(mbe.getAttributes());
GeneralInterfaceTemplate ifcTemplate = new GeneralInterfaceTemplate(
}
public static Map<String, GeneralClassTemplate> tOsFromMbe(
- ModuleMXBeanEntry mbe) {
+ final ModuleMXBeanEntry mbe) {
Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
TOAttributesProcessor processor = new TOAttributesProcessor();
processor.processAttributes(mbe.getAttributes());
}
public static Map<String, GeneralClassTemplate> tOsFromRbe(
- RuntimeBeanEntry rbe) {
+ final RuntimeBeanEntry rbe) {
Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
TOAttributesProcessor processor = new TOAttributesProcessor();
Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
return retVal;
}
- private static Header getHeaderFromEntry(AbstractEntry mbe) {
+ private static Header getHeaderFromEntry(final AbstractEntry mbe) {
return new Header(mbe.getYangModuleName(), mbe.getYangModuleLocalname());
}
private final List<TOInternal> tos = Lists.newArrayList();
- void processAttributes(Map<String, AttributeIfc> attributes) {
+ void processAttributes(final Map<String, AttributeIfc> attributes) {
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
AttributeIfc attributeIfc = attrEntry.getValue();
if (attributeIfc instanceof TOAttribute) {
}
}
- private void createTOInternal(TOAttribute toAttribute) {
+ private void createTOInternal(final TOAttribute toAttribute) {
Map<String, AttributeIfc> attrs = toAttribute.getCapitalizedPropertiesToTypesMap();
// recursive processing of TO's attributes
private List<Field> fields;
private List<MethodDefinition> methods;
- public TOInternal(Type type, Map<String, AttributeIfc> attrs) {
+ public TOInternal(final Type type, final Map<String, AttributeIfc> attrs) {
this(type.getFullyQualifiedName(), type.getName(), attrs, type.getPackageName());
}
- public TOInternal(String fullyQualifiedName, String name,
- Map<String, AttributeIfc> attrs, String packageName) {
+ public TOInternal(final String fullyQualifiedName, final String name,
+ final Map<String, AttributeIfc> attrs, final String packageName) {
this.fullyQualifiedName = fullyQualifiedName;
this.name = name;
processAttrs(attrs, packageName);
private final static String dependencyResolverVarName = "dependencyResolver";
private final static String dependencyResolverInjectMethodName = "injectDependencyResolver";
- private void processAttrs(Map<String, AttributeIfc> attrs, String packageName) {
+ private void processAttrs(final Map<String, AttributeIfc> attrs, final String packageName) {
fields = Lists.newArrayList();
methods = Lists.newArrayList();
for (Entry<String, AttributeIfc> attrEntry : attrs.entrySet()) {
String innerName = attrEntry.getKey();
- String varName = BindingGeneratorUtil
- .parseToValidParamName(attrEntry.getKey());
+ String varName = BindingMapping.getPropertyName(attrEntry.getKey());
String fullyQualifiedName, nullableDefault = null;
if (attrEntry.getValue() instanceof TypedAttribute) {
private static class MXBeanInterfaceAttributesProcessor {
private final List<MethodDeclaration> methods = Lists.newArrayList();
- void processAttributes(Map<String, AttributeIfc> attributes) {
+ void processAttributes(final Map<String, AttributeIfc> attributes) {
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
String returnType;
AttributeIfc attributeIfc = attrEntry.getValue();
MethodDeclaration getter = new MethodDeclaration(returnType,
getterName, Collections.<Field> emptyList());
- String varName = BindingGeneratorUtil
- .parseToValidParamName(attrEntry.getKey());
+ String varName = BindingMapping.getPropertyName(attrEntry.getKey());
String setterName = "set"
+ attributeIfc.getUpperCaseCammelCase();
MethodDeclaration setter = new MethodDeclaration("void",
private final List<Field> fields = Lists.newArrayList();
- void processAttributes(Map<String, AttributeIfc> attributes,
- String packageName) {
+ void processAttributes(final Map<String, AttributeIfc> attributes,
+ final String packageName) {
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
String type;
String nullableDefaultWrapped = null;
private final List<ModuleField> moduleFields;
private final List<MethodDefinition> methods;
- private Holder(List<ModuleField> moduleFields, List<MethodDefinition> methods) {
+ private Holder(final List<ModuleField> moduleFields, final List<MethodDefinition> methods) {
this.moduleFields = Collections.unmodifiableList(moduleFields);
this.methods = Collections.unmodifiableList(methods);
}
private final Holder holder;
- private AbstractModuleAttributesProcessor(Map<String, AttributeIfc> attributes) {
+ private AbstractModuleAttributesProcessor(final Map<String, AttributeIfc> attributes) {
this.holder = processAttributes(attributes);
}
- private static Holder processAttributes(Map<String, AttributeIfc> attributes) {
+ private static Holder processAttributes(final Map<String, AttributeIfc> attributes) {
List<ModuleField> moduleFields = new ArrayList<>();
List<MethodDefinition> methods = new ArrayList<>();
for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
}
}
- String varName = BindingGeneratorUtil
- .parseToValidParamName(attrEntry.getKey());
+ String varName = BindingMapping.getPropertyName(attrEntry.getKey());
ModuleField field;
if (isIdentity) {
}
- private static boolean needsDepResolver(AttributeIfc value) {
- if(value instanceof TOAttribute)
+ private static boolean needsDepResolver(final AttributeIfc value) {
+ if(value instanceof TOAttribute) {
return true;
+ }
if(value instanceof ListAttribute) {
AttributeIfc innerAttribute = ((ListAttribute) value).getInnerAttribute();
return needsDepResolver(innerAttribute);
return false;
}
- private static String getInnerTypeFromIdentity(Type type) {
+ private static String getInnerTypeFromIdentity(final Type type) {
Preconditions.checkArgument(type instanceof ParameterizedType);
Type[] args = ((ParameterizedType) type).getActualTypeArguments();
Preconditions.checkArgument(args.length ==1);