import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
} else {
generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
- (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
+ (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), null);
}
}
augSchema);
} else {
generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
- (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
+ (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes(), usesNodeParent);
}
}
* </ul>
*/
private void generateTypesFromAugmentedChoiceCases(final Module module, final String basePackageName,
- final Type targetType, final ChoiceSchemaNode targetNode, final Iterable<DataSchemaNode> augmentedNodes) {
+ final Type targetType, final ChoiceSchemaNode targetNode, final Iterable<DataSchemaNode> augmentedNodes,
+ final DataNodeContainer usesNodeParent) {
checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");
checkArgument(augmentedNodes != null, "Set of Choice Case Nodes cannot be NULL.");
}
ChoiceCaseNode node = null;
+ final String caseLocalName = caseNode.getQName().getLocalName();
if (caseNode instanceof ChoiceCaseNode) {
node = (ChoiceCaseNode) caseNode;
+ } else if (targetNode.getCaseNodeByName(caseLocalName) == null) {
+ final String targetNodeLocalName = targetNode.getQName().getLocalName();
+ for (DataSchemaNode dataSchemaNode : usesNodeParent.getChildNodes()) {
+ if (dataSchemaNode instanceof ChoiceSchemaNode && targetNodeLocalName.equals(dataSchemaNode.getQName
+ ().getLocalName())) {
+ node = ((ChoiceSchemaNode) dataSchemaNode).getCaseNodeByName(caseLocalName);
+ break;
+ }
+ }
} else {
- node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
+ node = targetNode.getCaseNodeByName(caseLocalName);
}
final Iterable<DataSchemaNode> childNodes = node.getChildNodes();
if (childNodes != null) {
builder.addAnnotation("", "Deprecated");
}
}
-}
+}
\ No newline at end of file