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.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.context.ModuleContext;
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.util.TypeComments;
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.YangSourceDefinition;
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;
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);
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);
+ processUsesImplements(module, module, schemaContext, genCtx, BindingNamespaceType.Data);
}
+ genCtx = notificationsToGenType(module, genCtx, schemaContext, genTypeBuilders, verboseClassComments, typeProvider);
+
//after potential parent data schema nodes
genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
genTypeBuilders, typeProvider);
* 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)}
+ * {@link GenHelperUtil#identityToGenType(Module, String, IdentitySchemaNode, SchemaContext, Map, boolean)}
* @param genCtx generated context
* @return returns generated context
*
final String basePackageName = BindingMapping.getRootPackageName(module);
if (schemaIdentities != null && !schemaIdentities.isEmpty()) {
- Map<QName, GeneratedTOBuilderImpl> generatedIdentities = new HashMap<>();
for (final IdentitySchemaNode identity : schemaIdentities) {
GenHelperUtil.identityToGenType(module, basePackageName, identity, schemaContext, genCtx,
- verboseClassComments, genTypeBuilders, typeProvider, generatedIdentities);
+ verboseClassComments);
}
}
return genCtx;
}
- final GeneratedTypeBuilder listenerInterface = moduleTypeBuilder(module, "Listener", verboseClassComments);
+ final GeneratedTypeBuilder listenerInterface = moduleTypeBuilder(module, "Listener", verboseClassComments,
+ genCtx.get(module));
listenerInterface.addImplementsType(NOTIFICATION_LISTENER);
final String basePackageName = BindingMapping.getRootPackageName(module);
if (notification != null) {
resolveNotification(listenerInterface, null, basePackageName, notification, module, schemaContext,
verboseClassComments, genTypeBuilders, typeProvider, genCtx);
+ processUsesImplements(notification, module, schemaContext, genCtx, BindingNamespaceType.Data);
}
}
resolveNotification(listenerInterface, potential.getQName().getLocalName(), basePackageName,
tiedNotification, module, schemaContext, verboseClassComments, genTypeBuilders,
typeProvider, genCtx);
+ processUsesImplements(tiedNotification, module, schemaContext, genCtx, BindingNamespaceType.Data);
}
}
}
}
- if (tiedNotifications != null) {
- listenerInterface.setDescription(createDescription(ImmutableSet.<NotificationDefinition>builder()
- .addAll(notifications).addAll(tiedNotifications).build(), module, verboseClassComments));
- } else {
- listenerInterface.setDescription(createDescription(notifications, module, verboseClassComments));
+ if (verboseClassComments) {
+ if (tiedNotifications != null) {
+ listenerInterface.setYangSourceDefinition(YangSourceDefinition.of(module,
+ ImmutableSet.<NotificationDefinition>builder().addAll(notifications).addAll(tiedNotifications)
+ .build()));
+ } else {
+ listenerInterface.setYangSourceDefinition(YangSourceDefinition.of(module, notifications));
+ }
+ listenerInterface.addComment(TypeComments.javadoc(
+ "Interface for receiving the following YANG notifications defined in module <b>" + module.getName()
+ + "</b>").get());
}
genCtx.get(module).addTopLevelNodeType(listenerInterface);