package org.opendaylight.yangtools.sal.binding.generator.impl;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+public final class BindingSchemaContextUtils {
-public class BindingSchemaContextUtils {
+ private BindingSchemaContextUtils() {
+ throw new UnsupportedOperationException("Utility class should not be instantiated");
+ }
// FIXME: THis method does not search in case augmentations.
public static Optional<DataNodeContainer> findDataNodeContainer(final SchemaContext ctx,
final QName targetQName) {
for (DataSchemaNode child : ctx.getChildNodes()) {
- if (child instanceof ChoiceNode) {
- DataNodeContainer potential = findInCases(((ChoiceNode) child), targetQName);
+ if (child instanceof ChoiceSchemaNode) {
+ DataNodeContainer potential = findInCases(((ChoiceSchemaNode) child), targetQName);
if (potential != null) {
return Optional.of(potential);
}
return Optional.absent();
}
- private static DataNodeContainer findInCases(final ChoiceNode choiceNode, final QName targetQName) {
+ private static DataNodeContainer findInCases(final ChoiceSchemaNode choiceNode, final QName targetQName) {
for (ChoiceCaseNode caze : choiceNode.getCases()) {
Optional<DataNodeContainer> potential = findDataNodeContainer(caze, targetQName);
if (potential.isPresent()) {
return augmentations;
}
- public static Optional<ChoiceNode> 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<ChoiceNode> 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 == null) {
potential = ctxNode.getDataChildByName(choiceName.getLocalName());
}
- if (potential instanceof ChoiceNode) {
- return Optional.of((ChoiceNode) potential);
+ if (potential instanceof ChoiceSchemaNode) {
+ return Optional.of((ChoiceSchemaNode) potential);
}
return Optional.absent();
}
- public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceNode instantiatedChoice, final ChoiceCaseNode originalDefinition) {
+ public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice, final ChoiceCaseNode originalDefinition) {
ChoiceCaseNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName());
if(originalDefinition.equals(potential)) {
return Optional.of(potential);
// This solves case, if choice was inside grouping
// which was used in different module and thus namespaces are
// different, but local names are still same.
- //
+ //
// Still we need to check equality of definition, because local name is not
// sufficient to uniquelly determine equality of cases
//