genCtx = allTypeDefinitionsToGenTypes(module, genCtx, typeProvider);
genCtx = groupingsToGenTypes(module, module.getGroupings(), genCtx, schemaContext, verboseClassComments,
genTypeBuilders, typeProvider);
- genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
- genTypeBuilders, typeProvider);
genCtx = allIdentitiesToGenTypes(module, schemaContext, genCtx, verboseClassComments, genTypeBuilders, typeProvider);
genCtx = notificationsToGenType(module, genCtx, schemaContext, genTypeBuilders, verboseClassComments, typeProvider);
.getChildNodes(), genCtx, schemaContext, verboseClassComments, genTypeBuilders, typeProvider);
}
+ //after potential parent data schema nodes
+ genCtx = actionsAndRPCMethodsToGenType(module, genCtx, schemaContext, verboseClassComments,
+ genTypeBuilders, typeProvider);
+
return genCtx;
}
import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.annotateDeprecatedIfNecessary;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.checkModuleAndModuleName;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.createDescription;
-import static org.opendaylight.mdsal.binding.javav2.generator.impl.AuxiliaryGenUtils.resolveListKeyTOBuilder;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.addImplementedInterfaceFromUses;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.addRawInterfaceDefinition;
import static org.opendaylight.mdsal.binding.javav2.generator.impl.GenHelperUtil.moduleTypeBuilder;
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.BindingGeneratorUtil;
import org.opendaylight.mdsal.binding.javav2.generator.util.BindingTypes;
+import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedTransferObject;
import org.opendaylight.mdsal.binding.javav2.model.api.GeneratedType;
-import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.GeneratedTOBuilder;
import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.GeneratedTypeBuilder;
import org.opendaylight.mdsal.binding.javav2.model.api.type.builder.MethodSignatureBuilder;
-import org.opendaylight.mdsal.binding.javav2.spec.runtime.BindingNamespaceType;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ActionDefinition;
import org.opendaylight.yangtools.yang.model.api.ActionNodeContainer;
*
*/
@Beta
-public final class RpcActionGenHelper {
+final class RpcActionGenHelper {
private static final QName CONTEXT_REFERENCE =
QName.create("urn:opendaylight:yang:extension:yang-ext", "2013-07-09", "context-reference").intern();
if (potential instanceof ActionNodeContainer) {
final Set<ActionDefinition> actions = ((ActionNodeContainer) potential).getActions();
for (ActionDefinition action: actions) {
- genCtx.get(module).addChildNodeType(potential, resolveOperation(potential, action, module,
+ genCtx.get(module).addTopLevelNodeType(resolveOperation(potential, action, module,
schemaContext, verboseClassComments, genTypeBuilders, genCtx, typeProvider, true));
}
}
//routedRPC?
if (isAction) {
- genCtx.get(module).addChildNodeType(parent, resolveOperation(parent, rpc, module, schemaContext,
+ genCtx.get(module).addTopLevelNodeType(resolveOperation(parent, rpc, module, schemaContext,
verboseClassComments, genTypeBuilders, genCtx, typeProvider, true));
} else {
//global RPC only
if (isAction) {
//action, routed RPC
- String packageName = BindingGeneratorUtil.packageNameForGeneratedType(basePackageName, parent.getPath(),
- BindingNamespaceType.Data);
- GeneratedTypeBuilder parentType = addRawInterfaceDefinition(packageName, parent, schemaContext,
- parent.getQName().getLocalName(), verboseClassComments, genTypeBuilders);
- parentType.addImplementsType(TREE_NODE);
- parentType.addImplementsType(augmentable(parentType));
+ checkState(parent != null, "Parent node of " + operation.getQName().getLocalName() + " can't be NULL");
+ GeneratedTypeBuilder parentType = genCtx.get(module).getChildNode(parent.getPath());
+ checkState(parentType != null, "Parent generated type for " + parent
+ + " data schema node must have been generated already");
annotateDeprecatedIfNecessary(parent.getStatus(), parentType);
- operationMethod.addParameter(parameterizedTypeFor(INSTANCE_IDENTIFIER, parentType), "ii");
-
if (parent instanceof ListSchemaNode) {
//ListAction
- final GeneratedTOBuilder keyType = resolveListKeyTOBuilder(basePackageName, (ListSchemaNode) parent);
+ GeneratedTransferObject keyType = null;
+ for (MethodSignatureBuilder method : parentType.getMethodDefinitions()) {
+ if (method.getName().equals("getKey")) {
+ keyType = (GeneratedTransferObject) method.toInstance(parentType).getReturnType();
+ }
+ }
+
operationMethod.addParameter(
parameterizedTypeFor(KEYED_INSTANCE_IDENTIFIER, parentType, keyType), "kii");
- operationMethod.setReturnType(keyType);
interfaceBuilder.addImplementsType(parameterizedTypeFor(LIST_ACTION, parentType, inType, outType));
} else {
//Action
} else {
//RPC
interfaceBuilder.addImplementsType(parameterizedTypeFor(RPC, inType, outType));
- interfaceBuilder.addImplementsType(TREE_NODE);
}
+ interfaceBuilder.addImplementsType(TREE_NODE);
operationMethod.addParameter(parameterizedTypeFor(RPC_CALLBACK, outType), "callback");
operationMethod.setComment(operationComment);