Merge "BUG-1954: Fix useless Boolean instantiation"
[yangtools.git] / yang / yang-data-operations / src / main / java / org / opendaylight / yangtools / yang / data / operations / ChoiceNodeModification.java
index 534c6a624082cac32627ee50fc306bb195168884..bd518fd00e35c14fa17175daf7eda2a39f4527ad 100644 (file)
@@ -7,21 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.data.operations;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.SchemaUtils;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.Sets;
-
 final class ChoiceNodeModification extends
         AbstractContainerNodeModification<ChoiceNode, org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode> {
 
@@ -36,28 +33,28 @@ final class ChoiceNodeModification extends
     }
 
     @Override
-    protected Set<InstanceIdentifier.PathArgument> getChildrenToProcess(ChoiceNode schema,
+    protected Set<YangInstanceIdentifier.PathArgument> getChildrenToProcess(ChoiceNode schema,
             Optional<org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode> actual,
             Optional<org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode> modification)
             throws DataModificationException {
-        Set<InstanceIdentifier.PathArgument> childrenToProcess = super.getChildrenToProcess(schema, actual,
+        Set<YangInstanceIdentifier.PathArgument> childrenToProcess = super.getChildrenToProcess(schema, actual,
                 modification);
 
-        if (modification.isPresent() == false) {
+        if (!modification.isPresent()) {
             return childrenToProcess;
         }
 
         // Detect case node from modification
         ChoiceCaseNode detectedCase = null;
-        for (DataContainerChild<? extends InstanceIdentifier.PathArgument, ?> child : modification.get().getValue()) {
+        for (DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> child : modification.get().getValue()) {
             Optional<ChoiceCaseNode> detectedCaseForChild = SchemaUtils.detectCase(schema, child);
 
-            if(detectedCaseForChild.isPresent() == false) {
+            if(!detectedCaseForChild.isPresent()) {
                 DataModificationException.IllegalChoiceValuesException.throwUnknownChild(schema.getQName(),
                         child.getNodeType());
             }
 
-            if (detectedCase != null && detectedCase.equals(detectedCaseForChild.get()) == false) {
+            if (detectedCase != null && (!detectedCase.equals(detectedCaseForChild.get()))) {
                 DataModificationException.IllegalChoiceValuesException.throwMultipleCasesReferenced(schema.getQName(),
                         modification.get(), detectedCase.getQName(), detectedCaseForChild.get().getQName());
             }
@@ -69,14 +66,14 @@ final class ChoiceNodeModification extends
 
         // Filter out child nodes that do not belong to detected case =
         // Nodes from other cases present in actual
-        Set<InstanceIdentifier.PathArgument> childrenToProcessFiltered = Sets.newLinkedHashSet();
-        for (InstanceIdentifier.PathArgument childToProcess : childrenToProcess) {
+        Set<YangInstanceIdentifier.PathArgument> childrenToProcessFiltered = Sets.newLinkedHashSet();
+        for (YangInstanceIdentifier.PathArgument childToProcess : childrenToProcess) {
             // child from other cases, skip
-            if (childToProcess instanceof AugmentationNode
-                    && SchemaUtils.belongsToCaseAugment(detectedCase,
-                            (InstanceIdentifier.AugmentationIdentifier) childToProcess) == false) {
+            if (childToProcess instanceof YangInstanceIdentifier.AugmentationIdentifier
+                    && (!SchemaUtils.belongsToCaseAugment(detectedCase,
+                            (YangInstanceIdentifier.AugmentationIdentifier) childToProcess))) {
                 continue;
-            } else if (belongsToCase(detectedCase, childToProcess) == false) {
+            } else if (!belongsToCase(detectedCase, childToProcess)) {
                 continue;
             }
 
@@ -86,12 +83,12 @@ final class ChoiceNodeModification extends
         return childrenToProcessFiltered;
     }
 
-    private boolean belongsToCase(ChoiceCaseNode detectedCase, InstanceIdentifier.PathArgument childToProcess) {
+    private boolean belongsToCase(ChoiceCaseNode detectedCase, YangInstanceIdentifier.PathArgument childToProcess) {
         return detectedCase.getDataChildByName(childToProcess.getNodeType()) != null;
     }
 
     @Override
-    protected Object findSchemaForAugment(ChoiceNode schema, InstanceIdentifier.AugmentationIdentifier childToProcessId) {
+    protected Object findSchemaForAugment(ChoiceNode schema, YangInstanceIdentifier.AugmentationIdentifier childToProcessId) {
         return SchemaUtils.findSchemaForAugment(schema, childToProcessId.getPossibleChildNames());
     }