X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding2%2Fmdsal-binding2-generator-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fjavav2%2Fgenerator%2Fimpl%2FModuleToGenType.java;h=ab9567d2403ef981241a87644768abbe5c571b08;hb=4178b9af2ee9bcdf6aa5126b31854625f813abbc;hp=10f3f44ff2db1c738f9d7e2542ec7ee5d6acf155;hpb=366dfa184c09f8817df9a4ecdd17e6d46a07f65d;p=mdsal.git
diff --git a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/ModuleToGenType.java b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/ModuleToGenType.java
index 10f3f44ff2..ab9567d240 100644
--- a/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/ModuleToGenType.java
+++ b/binding2/mdsal-binding2-generator-impl/src/main/java/org/opendaylight/mdsal/binding/javav2/generator/impl/ModuleToGenType.java
@@ -10,22 +10,30 @@ package org.opendaylight.mdsal.binding.javav2.generator.impl;
import static com.google.common.base.Preconditions.checkArgument;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.createDescription;
+import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.groupingsToGenTypes;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.moduleTypeBuilder;
+import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.processUsesImplements;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.resolveNotification;
import static org.opendaylight.mdsal.binding.javav2.generator.util.BindingTypes.NOTIFICATION_LISTENER;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opendaylight.mdsal.binding.javav2.generator.spi.TypeProvider;
+import org.opendaylight.mdsal.binding.javav2.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
import org.opendaylight.mdsal.binding.javav2.generator.yang.types.TypeProviderImpl;
import org.opendaylight.mdsal.binding.javav2.model.api.Type;
import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.GeneratedTypeBuilder;
+import org.opendaylight.mdsal.binding.javav2.spec.runtime.BindingNamespaceType;
import org.opendaylight.mdsal.binding.javav2.util.BindingMapping;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.NotificationNodeContainer;
@@ -46,20 +54,24 @@ final class ModuleToGenType {
genCtx.put(module, new ModuleContext());
genCtx = allTypeDefinitionsToGenTypes(module, genCtx, typeProvider);
- genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
+ genCtx = groupingsToGenTypes(module, module.getGroupings(), genCtx, schemaContext, verboseClassComments,
genTypeBuilders, typeProvider);
+ genCtx = allIdentitiesToGenTypes(module, schemaContext, genCtx, verboseClassComments, genTypeBuilders, typeProvider);
genCtx = notificationsToGenType(module, genCtx, schemaContext, genTypeBuilders, verboseClassComments, typeProvider);
- //TODO: call generate for other entities (groupings, identities)
-
if (!module.getChildNodes().isEmpty()) {
final GeneratedTypeBuilder moduleType = GenHelperUtil.moduleToDataType(module, genCtx, verboseClassComments);
genCtx.get(module).addModuleNode(moduleType);
final String basePackageName = BindingMapping.getRootPackageName(module);
GenHelperUtil.resolveDataSchemaNodes(module, basePackageName, moduleType, moduleType, module
- .getChildNodes(), genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
+ .getChildNodes(), genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider,
+ BindingNamespaceType.Data);
}
+ //after potential parent data schema nodes
+ genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
+ genTypeBuilders, typeProvider);
+
return genCtx;
}
@@ -109,6 +121,37 @@ final class ModuleToGenType {
return genCtx;
}
+ /**
+ * Converts all identities of the module to the list of
+ * Type
objects.
+ *
+ * @param module
+ * module from which is obtained set of all identity objects to
+ * iterate over them
+ * @param schemaContext
+ * schema context only used as input parameter for method
+ * {@link GenHelperUtil#identityToGenType(Module, String, IdentitySchemaNode, SchemaContext, Map, boolean, Map, TypeProvider, Map)}
+ * @param genCtx generated context
+ * @return returns generated context
+ *
+ */
+ private static Map allIdentitiesToGenTypes(final Module module,
+ final SchemaContext schemaContext, Map genCtx, boolean verboseClassComments,
+ final Map> genTypeBuilders, final TypeProvider typeProvider) {
+
+ final Set schemaIdentities = module.getIdentities();
+ final String basePackageName = BindingMapping.getRootPackageName(module);
+
+ if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
+ for (final IdentitySchemaNode identity : schemaIdentities) {
+ GenHelperUtil.identityToGenType(module, basePackageName, identity, schemaContext, genCtx,
+ verboseClassComments);
+ }
+ }
+
+ return genCtx;
+ }
+
/**
* Converts all notifications of the module to the list of
* Type
objects. In addition are to this list added containers
@@ -143,28 +186,35 @@ final class ModuleToGenType {
if (notification != null) {
resolveNotification(listenerInterface, null, basePackageName, notification, module, schemaContext,
verboseClassComments, genTypeBuilders, typeProvider, genCtx);
+ processUsesImplements(notification, module, schemaContext, genCtx, BindingNamespaceType.Data);
}
}
//YANG 1.1 allows notifications be tied to containers and lists
final Collection potentials = module.getChildNodes();
+ Set tiedNotifications = null;
for (final DataSchemaNode potential : potentials) {
if (potential instanceof NotificationNodeContainer) {
- final Set tiedNotifications = ((NotificationNodeContainer) potential)
+ tiedNotifications = ((NotificationNodeContainer) potential)
.getNotifications();
for (final NotificationDefinition tiedNotification: tiedNotifications) {
if (tiedNotification != null) {
resolveNotification(listenerInterface, potential.getQName().getLocalName(), basePackageName,
tiedNotification, module, schemaContext, verboseClassComments, genTypeBuilders,
typeProvider, genCtx);
- notifications.add(tiedNotification);
+ processUsesImplements(tiedNotification, module, schemaContext, genCtx, BindingNamespaceType.Data);
}
}
}
}
- listenerInterface.setDescription(createDescription(notifications, module, verboseClassComments));
+ if (tiedNotifications != null) {
+ listenerInterface.setDescription(createDescription(ImmutableSet.builder()
+ .addAll(notifications).addAll(tiedNotifications).build(), module, verboseClassComments));
+ } else {
+ listenerInterface.setDescription(createDescription(notifications, module, verboseClassComments));
+ }
genCtx.get(module).addTopLevelNodeType(listenerInterface);