import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.common.Revision;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
for (DataSchemaNode child : ctx.getChildNodes()) {
if (child instanceof ChoiceSchemaNode) {
- DataNodeContainer potential = findInCases(((ChoiceSchemaNode) child), targetQName);
+ DataNodeContainer potential = findInCases((ChoiceSchemaNode) child, targetQName);
if (potential != null) {
return Optional.of(potential);
}
}
private static DataNodeContainer findInCases(final ChoiceSchemaNode choiceNode, final QName targetQName) {
- for (ChoiceCaseNode caze : choiceNode.getCases()) {
+ for (CaseSchemaNode caze : choiceNode.getCases().values()) {
Optional<DataNodeContainer> potential = findDataNodeContainer(caze, targetQName);
if (potential.isPresent()) {
return potential.get();
for(RpcDefinition rpc : ctx.getOperations()) {
String rpcNamespace = rpc.getQName().getNamespace().toString();
- String rpcRevision = rpc.getQName().getFormattedRevision();
+ String rpcRevision = rpc.getQName().getRevision().map(Revision::toString).orElse(null);
if(moduleInfo.getNamespace().equals(rpcNamespace) && moduleInfo.getRevision().equals(rpcRevision)) {
Optional<DataNodeContainer> potential = findInputOutput(rpc,targetType.getSimpleName());
if(potential.isPresent()) {
return Optional.absent();
}
- public static Set<AugmentationSchema> collectAllAugmentationDefinitions(final SchemaContext currentSchema, final AugmentationTarget ctxNode) {
- HashSet<AugmentationSchema> augmentations = new HashSet<>();
+ public static Set<AugmentationSchemaNode> collectAllAugmentationDefinitions(final SchemaContext currentSchema,
+ final AugmentationTarget ctxNode) {
+ HashSet<AugmentationSchemaNode> augmentations = new HashSet<>();
augmentations.addAll(ctxNode.getAvailableAugmentations());
if(ctxNode instanceof DataSchemaNode && ((DataSchemaNode) ctxNode).isAddedByUses()) {
return augmentations;
}
- public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer parent, final Class<?> choiceClass) {
+ public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer parent,
+ final Class<?> choiceClass) {
return findInstantiatedChoice(parent, BindingReflections.findQName(choiceClass));
}
- public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer ctxNode, final QName choiceName) {
+ public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer ctxNode,
+ final QName choiceName) {
DataSchemaNode potential = ctxNode.getDataChildByName(choiceName);
if (potential instanceof ChoiceSchemaNode) {
return Optional.of((ChoiceSchemaNode) potential);
return Optional.absent();
}
- public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice, final ChoiceCaseNode originalDefinition) {
- ChoiceCaseNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName());
+ public static Optional<CaseSchemaNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice,
+ final CaseSchemaNode originalDefinition) {
+ CaseSchemaNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName());
if(originalDefinition.equals(potential)) {
return Optional.of(potential);
}
return Optional.of(potential);
}
}
+
// We try to find case by name, then lookup its root definition
// and compare it with original definition
// This solves case, if choice was inside grouping
// Still we need to check equality of definition, because local name is not
// sufficient to uniquelly determine equality of cases
//
- potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName().getLocalName());
- if(potential != null && (originalDefinition.equals(SchemaNodeUtils.getRootOriginalIfPossible(potential)))) {
- return Optional.of(potential);
+ for (CaseSchemaNode caze : instantiatedChoice.findCaseNodes(originalDefinition.getQName().getLocalName())) {
+ if (originalDefinition.equals(SchemaNodeUtils.getRootOriginalIfPossible(caze))) {
+ return Optional.of(caze);
+ }
}
return Optional.absent();
}