Cleanup checkstyle warnings and turn enforcement on in yang-data-impl 51/62551/6
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 1 Sep 2017 13:28:30 +0000 (15:28 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Oct 2017 08:01:16 +0000 (10:01 +0200)
This patch cleans up bunch of old code to comply with checkstyle rules
and flips the switch so we do not regress.

Change-Id: I2b314d2a672e9b0b7fb225004fd1f3ce770f098a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
164 files changed:
yang/yang-data-impl/pom.xml
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/AbstractIntegerStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/CompiledPatternContext.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/DecimalStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/DeserializationException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/EnumStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/Int16StringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/Int32StringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/Int64StringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/Int8StringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/SchemaTracker.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/StringPatternCheckingCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/StringStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/TypeDefinitionAwareCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/UnionStringCodec.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefContext.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefContextBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefContextTreeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefDataValidationFailedException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPath.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPathErrorListener.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPathParserImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPathParserListenerImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefPathSyntaxErrorException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/LeafRefValidatation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/QNamePredicateBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/QNamePredicateImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/QNameWithPredicateBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/leafref/QNameWithPredicateImpl.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/Builders.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNodes.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNormalizedNodeStreamWriter.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToCompositeNodes.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodes.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToSimpleNodes.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeResult.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/ResultAlreadySetException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaOrderedNormalizedNodeWriter.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtils.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/api/CollectionNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/api/DataContainerNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/api/NormalizedNodeContainerBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/AbstractImmutableDataContainerNodeAttrBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/AbstractImmutableDataContainerNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/AbstractImmutableNormalizedNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableChoiceNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableChoiceNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableContainerNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableContainerNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetEntryNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapEntryNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapEntryNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedMapNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedMapNodeSchemaAwareBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListEntryNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableYangModeledAnyXmlNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/valid/DataNodeContainerValidator.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/valid/DataValidationException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/AbstractImmutableDataContainerNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/AbstractImmutableNormalizedNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/AbstractImmutableNormalizedValueAttrNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/UnmodifiableChildrenMap.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractCursorAware.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataNodeContainerModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractDataTreeTip.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractModifiedNodeBasedCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractNodeContainerModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractRecursiveCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractValueNodeModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AugmentationModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ChoiceModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DeleteLeafCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeCandidate.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeFactory.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModification.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeModificationCursor.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeSnapshot.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeSnapshotCursor.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/LatestOperationHolder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/MandatoryLeafEnforcer.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationApplyOperation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModifiedNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NoopDataTreeCandidate.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/NotUpgradableModificationApplyOperation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/OperationWithModification.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/PresenceContainerModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/RecursiveDeleteCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/RecursiveReplaceCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/RecursiveUnmodifiedCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/RecursiveWriteCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/RootModificationApplyOperation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaValidationFailedException.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StructuralContainerModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnkeyedListModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnmodifiedLeafCandidateNode.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnorderedMapModificationStrategy.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UpgradableModificationApplyOperation.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/WriteLeafCandidateNode.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/IgnoreWhiteCharsDiffListener.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/MemoryConsumption.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/BinaryCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/BitsCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/DecimalCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/EmptyCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/EnumCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Int16CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Int32CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Int64CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Int8CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/StringCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/StringPatternCheckingCodecTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/TypeDefinitionAwareCodecTestHelper.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Uint16CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Uint32CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Uint64CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/Uint8CodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/UnionCodecStringTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest2.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest3.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/LeafRefContextTreeBuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/BuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/ImmutableNormalizedNodeStreamWriterTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedNodeUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/nodes/AbstractImmutableNormalizedValueAttrNodeTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4295Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4454Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5830Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5968MergeTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5968Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/CaseAugmentTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ConcurrentTreeModificationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ConfigStatementValidationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DataTreeCandidatesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DataTreeTransactionTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ErrorReportingTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidation.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/MandatoryLeafTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationMetadataTreeTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/OrderedListTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StoreTreeNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TestModel.java

index 415191ef616a91526b97c43883e53a8c36f2d61c..6c4b0c6b9493400c85afacf7d9747f4b345dd395 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <configuration>
+                    <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
         </dependency>
     </dependencies>
 
-  <!--
-      Maven Site Configuration
-
-      The following configuration is necessary for maven-site-plugin to
-      correctly identify the correct deployment path for OpenDaylight Maven
-      sites.
-  -->
-  <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
-
-  <distributionManagement>
-    <site>
-      <id>opendaylight-site</id>
-      <url>${nexus.site.url}/${project.artifactId}/</url>
-    </site>
-  </distributionManagement>
+    <!--
+        Maven Site Configuration
+        The following configuration is necessary for maven-site-plugin to
+        correctly identify the correct deployment path for OpenDaylight Maven
+        sites.
+    -->
+    <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+    <distributionManagement>
+        <site>
+            <id>opendaylight-site</id>
+            <url>${nexus.site.url}/${project.artifactId}/</url>
+        </site>
+    </distributionManagement>
 </project>
index 4102943b4087f9a5ca136d37fb885bcc31ab9481..fa2ab757c79c1dafc9c6f516ec372b08c1d4bf93 100644 (file)
@@ -44,12 +44,12 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
     // For up to two characters, this is very fast
     private static final CharMatcher X_MATCHER = CharMatcher.anyOf("xX");
 
-    private static final String INCORRECT_LEXICAL_REPRESENTATION = "Incorrect lexical representation of integer value: %s."
-            + "\nAn integer value can be defined as: "
-            + "\n  - a decimal number,"
-            + "\n  - a hexadecimal number (prefix 0x)," + "%n  - an octal number (prefix 0)."
-            + "\nSigned values are allowed. Spaces between digits are NOT allowed.";
-
+    private static final String INCORRECT_LEXICAL_REPRESENTATION =
+            "Incorrect lexical representation of integer value: %s."
+                    + "\nAn integer value can be defined as: "
+                    + "\n  - a decimal number,"
+                    + "\n  - a hexadecimal number (prefix 0x)," + "%n  - an octal number (prefix 0)."
+                    + "\nSigned values are allowed. Spaces between digits are NOT allowed.";
 
     private final List<Range<N>> rangeConstraints;
 
@@ -133,6 +133,17 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
         return deserialized;
     }
 
+    /**
+     * Deserializes value from supplied string representation is supplied radix. See
+     * {@link Integer#parseInt(String, int)} for in-depth description about string and radix relationship.
+     *
+     * @param stringRepresentation String representation
+     * @param radix numeric base.
+     * @return Deserialized value.
+     */
+    abstract N deserialize(String stringRepresentation, int radix);
+
+    abstract N convertValue(Number value);
 
     private void validate(final N value) {
         if (rangeConstraints.isEmpty()) {
@@ -146,22 +157,6 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
         throw new IllegalArgumentException("Value '" + value + "'  is not in required range " + rangeConstraints);
     }
 
-    /**
-     * Deserializes value from supplied string representation
-     * is supplied radix.
-     *
-     * See {@link Integer#parseInt(String, int)} for in-depth
-     * description about string and radix relationship.
-     *
-     * @param stringRepresentation String representation
-     * @param radix numeric base.
-     * @return Deserialized value.
-     */
-    abstract N deserialize(String stringRepresentation, int radix);
-
-    abstract N convertValue(Number value);
-
-
     protected static List<RangeConstraint> extractRange(final IntegerTypeDefinition type) {
         if (type == null) {
             return Collections.emptyList();
index 6e9012229510ddedbb6e41295b844d8ce2b7319b..d6f5505e51cba3d2f430ec3c8d84914c2928d52e 100644 (file)
@@ -27,8 +27,7 @@ class CompiledPatternContext {
         }
     }
 
-    public void validate(final String s) {
-        Preconditions.checkArgument(pattern.matcher(s).matches(), errorMessage, s);
+    public void validate(final String str) {
+        Preconditions.checkArgument(pattern.matcher(str).matches(), errorMessage, str);
     }
-
 }
\ No newline at end of file
index 7abc126c1109bfa80c8866c3f1f4e156bdbcfc0e..3594c085dbcbebddf568a57753cf3311efb9221f 100644 (file)
@@ -37,7 +37,7 @@ public final class DecimalStringCodec extends TypeDefinitionAwareCodec<BigDecima
 
     @Override
     public BigDecimal deserialize(final String stringRepresentation) {
-        Preconditions.checkArgument( stringRepresentation != null , "Input cannot be null" );
+        Preconditions.checkArgument(stringRepresentation != null, "Input cannot be null");
         // FIXME: run value validation
         return new BigDecimal(stringRepresentation);
     }
index 3cea38a974e389e11a0131aec22f59b8c953936b..f86a47c82934549536836a500c25d60f94c0d68d 100644 (file)
@@ -13,19 +13,20 @@ public class DeserializationException extends Exception {
     public DeserializationException() {
     }
 
-    public DeserializationException(String message) {
+    public DeserializationException(final String message) {
         super(message);
     }
 
-    public DeserializationException(Throwable cause) {
+    public DeserializationException(final Throwable cause) {
         super(cause);
     }
 
-    public DeserializationException(String message, Throwable cause) {
+    public DeserializationException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
-    public DeserializationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+    public DeserializationException(final String message, final Throwable cause, final boolean enableSuppression,
+            final boolean writableStackTrace) {
         super(message, cause, enableSuppression, writableStackTrace);
     }
 
index 396823ca893ebca3297684571946199a7adc3863..9cc8f1593da06024c58d6b90c87cbb12c61fc4b3 100644 (file)
@@ -46,16 +46,16 @@ public final class EnumStringCodec extends TypeDefinitionAwareCodec<String, Enum
     }
 
     @Override
-    public String deserialize(final String s) {
+    public String deserialize(final String stringRepresentation) {
         if (values == null) {
-            return s;
+            return stringRepresentation;
         }
 
         // Lookup the serialized string in the values. Returned string is the interned instance, which we want
         // to use as the result.
-        final String result = values.get(s);
+        final String result = values.get(stringRepresentation);
         Preconditions.checkArgument(result != null, "Invalid value '%s' for enum type. Allowed values are: %s",
-                s, values.keySet());
+                stringRepresentation, values.keySet());
         return result;
     }
 
index 0493f8b8bdb0f94000b874434cc4e0657dd8be3e..245af4e268eae9a5e143c56f8bfbe06d5cf65805 100644 (file)
@@ -13,7 +13,8 @@ import java.util.Objects;
 import org.opendaylight.yangtools.yang.data.api.codec.Int16Codec;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
-final class Int16StringCodec extends AbstractIntegerStringCodec<Short, IntegerTypeDefinition> implements Int16Codec<String> {
+final class Int16StringCodec extends AbstractIntegerStringCodec<Short, IntegerTypeDefinition>
+        implements Int16Codec<String> {
     Int16StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
         super(typeDef, extractRange(typeDef.orNull()), Short.class);
     }
index 24654757bc8abc74a69454a180218097892d80b3..efa27134e5193ae7f661615e2af09d9da20c9ca3 100644 (file)
@@ -13,7 +13,8 @@ import java.util.Objects;
 import org.opendaylight.yangtools.yang.data.api.codec.Int32Codec;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
-final class Int32StringCodec extends AbstractIntegerStringCodec<Integer, IntegerTypeDefinition> implements Int32Codec<String> {
+final class Int32StringCodec extends AbstractIntegerStringCodec<Integer, IntegerTypeDefinition>
+        implements Int32Codec<String> {
     Int32StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
         super(typeDef, extractRange(typeDef.orNull()), Integer.class);
     }
index 89feceb9fda5cc188e3d9b5e06427408ce68e745..5fec6f37c03d7b1ad161f472bd94854d205d4c44 100644 (file)
@@ -13,7 +13,8 @@ import java.util.Objects;
 import org.opendaylight.yangtools.yang.data.api.codec.Int64Codec;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
-final class Int64StringCodec extends AbstractIntegerStringCodec<Long, IntegerTypeDefinition> implements Int64Codec<String> {
+final class Int64StringCodec extends AbstractIntegerStringCodec<Long, IntegerTypeDefinition>
+        implements Int64Codec<String> {
 
     Int64StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
         super(typeDef, extractRange(typeDef.orNull()), Long.class);
index fd938ed99a70ef84948cd394bf8bd55372683cb7..cf06b860fc52c60eae2402ef72d02b83f0bdb423 100644 (file)
@@ -13,7 +13,8 @@ import java.util.Objects;
 import org.opendaylight.yangtools.yang.data.api.codec.Int8Codec;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
-final class Int8StringCodec extends AbstractIntegerStringCodec<Byte, IntegerTypeDefinition> implements Int8Codec<String> {
+final class Int8StringCodec extends AbstractIntegerStringCodec<Byte, IntegerTypeDefinition>
+        implements Int8Codec<String> {
 
     Int8StringCodec(final Optional<IntegerTypeDefinition> typeDef) {
         super(typeDef, extractRange(typeDef.orNull()), Byte.class);
index 1609aaa597c29847eff9b3cec1de50808616d917..60ffd77d0f04a2655076adeddb15675fe4d6b4a2 100644 (file)
@@ -79,11 +79,10 @@ public final class SchemaTracker {
     }
 
     /**
-     * Create a new writer with the specified context and rooted in the specified schema path
+     * Create a new writer with the specified context and rooted in the specified schema path.
      *
      * @param context Associated {@link SchemaContext}
      * @param path schema path
-     *
      * @return A new {@link NormalizedNodeStreamWriter}
      */
     public static SchemaTracker create(final SchemaContext context, final SchemaPath path) {
@@ -113,7 +112,7 @@ public final class SchemaTracker {
         } else if (parent instanceof ChoiceSchemaNode) {
             schema = findChildInCases((ChoiceSchemaNode) parent, qname);
         } else {
-            throw new IllegalStateException("Unsupported schema type "+ parent.getClass() +" on stack.");
+            throw new IllegalStateException("Unsupported schema type " + parent.getClass() + " on stack.");
         }
 
         Preconditions.checkArgument(schema != null, "Could not find schema for node %s in %s", qname, parent);
@@ -166,7 +165,8 @@ public final class SchemaTracker {
     public LeafListSchemaNode startLeafSet(final NodeIdentifier name) {
         final SchemaNode schema = getSchema(name);
 
-        Preconditions.checkArgument(schema instanceof LeafListSchemaNode, "Node %s is not a leaf-list", schema.getPath());
+        Preconditions.checkArgument(schema instanceof LeafListSchemaNode, "Node %s is not a leaf-list",
+            schema.getPath());
         schemaStack.push(schema);
         return (LeafListSchemaNode)schema;
     }
@@ -234,8 +234,10 @@ public final class SchemaTracker {
             final QName name = Iterables.get(identifier.getPossibleChildNames(), 0);
             parent = findCaseByChild((ChoiceSchemaNode) parent, name);
         }
-        Preconditions.checkArgument(parent instanceof DataNodeContainer, "Augmentation allowed only in DataNodeContainer",parent);
-        final AugmentationSchema schema = SchemaUtils.findSchemaForAugment((AugmentationTarget) parent, identifier.getPossibleChildNames());
+        Preconditions.checkArgument(parent instanceof DataNodeContainer,
+            "Augmentation allowed only in DataNodeContainer", parent);
+        final AugmentationSchema schema = SchemaUtils.findSchemaForAugment((AugmentationTarget) parent,
+            identifier.getPossibleChildNames());
         final HashSet<DataSchemaNode> realChildSchemas = new HashSet<>();
         for (final DataSchemaNode child : schema.getChildNodes()) {
             realChildSchemas.add(((DataNodeContainer) parent).getDataChildByName(child.getQName()));
@@ -255,5 +257,4 @@ public final class SchemaTracker {
     public Object endNode() {
         return schemaStack.pop();
     }
-
 }
index 51ef4556892e8483ed6ae4f8c9786aa89af4af2e..c7541830e1b2103090216987e5e7086364353b7c 100644 (file)
@@ -16,8 +16,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class StringPatternCheckingCodec extends StringStringCodec {
-
     private static final Logger LOG = LoggerFactory.getLogger(StringPatternCheckingCodec.class);
+
     private final Collection<CompiledPatternContext> patterns;
 
     StringPatternCheckingCodec(final StringTypeDefinition typeDef) {
@@ -33,10 +33,10 @@ final class StringPatternCheckingCodec extends StringStringCodec {
     }
 
     @Override
-    void validate(final String s) {
-        super.validate(s);
+    void validate(final String str) {
+        super.validate(str);
         for (final CompiledPatternContext pattern : patterns) {
-            pattern.validate(s);
+            pattern.validate(str);
         }
     }
 
index 270eb52b691c77553a4f9f645e2ae4a5141cb328..9a608bf977db62691363fbe732926fb7a7f5242f 100644 (file)
@@ -68,9 +68,9 @@ public class StringStringCodec extends TypeDefinitionAwareCodec<String, StringTy
         return Objects.toString(data, "");
     }
 
-    void validate(final String s) {
+    void validate(final String str) {
         if (lengths != null) {
-            Preconditions.checkArgument(lengths.contains(s.length()), "String '%s' does not match allowed lengths %s",
+            Preconditions.checkArgument(lengths.contains(str.length()), "String '%s' does not match allowed lengths %s",
                 lengths);
         }
     }
index ef0bb525798d443e1456688a6eab7d3cc5ecae6a..ab1f8289ca3e4a9e59887e565bb945553866fd38 100644 (file)
@@ -41,7 +41,8 @@ public abstract class TypeDefinitionAwareCodec<J, T extends TypeDefinition<T>> i
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    public static TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> from(final TypeDefinition typeDefinition) {
+    public static TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>> from(
+            final TypeDefinition typeDefinition) {
         return (TypeDefinitionAwareCodec)fromType(typeDefinition);
     }
 
index 1ec5ba5c2551aada37e232cbbca36b801d1ed648..a811428146f5e8102c52b6b310f0a78403795615 100644 (file)
@@ -17,9 +17,10 @@ import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class UnionStringCodec extends TypeDefinitionAwareCodec<Object, UnionTypeDefinition> implements UnionCodec<String> {
+final class UnionStringCodec extends TypeDefinitionAwareCodec<Object, UnionTypeDefinition>
+        implements UnionCodec<String> {
 
-    private final static Logger LOG = LoggerFactory.getLogger(UnionStringCodec.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UnionStringCodec.class);
 
     private UnionStringCodec(final Optional<UnionTypeDefinition> typeDef) {
         super(typeDef, Object.class);
@@ -38,6 +39,7 @@ final class UnionStringCodec extends TypeDefinitionAwareCodec<Object, UnionTypeD
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public Object deserialize(final String stringRepresentation) {
 
         if (!getTypeDefinition().isPresent()) {
index cb33d9c6d7429b0a04ff99a4d11f92ff14858219..fcf06813cabb490b5c35635518afac42c6a9b110 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
-final public class LeafRefContext {
+public final class LeafRefContext {
 
     private final QName currentNodeQName;
     private final SchemaPath currentNodePath;
index ea609045c36048c24c49ccd847b6377f610a95b2..23f585b6de64fee388db44e9214e95a27bf31099 100644 (file)
@@ -10,13 +10,18 @@ package org.opendaylight.yangtools.yang.data.impl.leafref;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
-class LeafRefContextBuilder {
+class LeafRefContextBuilder implements Builder<LeafRefContext> {
+
+    private final Map<QName, LeafRefContext> referencingChildren = new HashMap<>();
+    private final Map<QName, LeafRefContext> referencedByChildren = new HashMap<>();
+    private final Map<QName, LeafRefContext> referencedByLeafRefCtx = new HashMap<>();
 
     private QName currentNodeQName;
     private SchemaPath currentNodePath;
@@ -29,17 +34,14 @@ class LeafRefContextBuilder {
     private boolean isReferencedBy = false;
     private boolean isReferencing = false;
 
-    private final Map<QName, LeafRefContext> referencingChildren = new HashMap<>();
-    private final Map<QName, LeafRefContext> referencedByChildren = new HashMap<>();
-    private final Map<QName, LeafRefContext> referencedByLeafRefCtx = new HashMap<>();
-
-    public LeafRefContextBuilder(final QName currentNodeQName,
-            final SchemaPath currentNodePath, final SchemaContext schemaContext) {
+    LeafRefContextBuilder(final QName currentNodeQName, final SchemaPath currentNodePath,
+        final SchemaContext schemaContext) {
         this.currentNodeQName = currentNodeQName;
         this.currentNodePath = currentNodePath;
         this.schemaContext = schemaContext;
     }
 
+    @Override
     public LeafRefContext build() {
         final LeafRefContext leafRefContext = new LeafRefContext(this);
 
@@ -176,5 +178,4 @@ class LeafRefContextBuilder {
     public Map<QName, LeafRefContext> getAllReferencedByLeafRefCtxs() {
         return referencedByLeafRefCtx;
     }
-
 }
index 20d2f1e267ffb008c15ed27c519a60aeab88a7da..9fddc90c745e878f82bf1064be7bb564b3944f43 100644 (file)
@@ -29,19 +29,17 @@ import org.opendaylight.yangtools.yang.model.api.TypedSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 
 class LeafRefContextTreeBuilder {
+    private final List<LeafRefContext> leafRefs = new LinkedList<>();
     private final SchemaContext schemaContext;
-    private final List<LeafRefContext> leafRefs;
 
-    public LeafRefContextTreeBuilder(final SchemaContext schemaContext) {
+    LeafRefContextTreeBuilder(final SchemaContext schemaContext) {
         this.schemaContext = schemaContext;
-        this.leafRefs = new LinkedList<>();
     }
 
     public LeafRefContext buildLeafRefContextTree() throws IOException,
             LeafRefYangSyntaxErrorException {
-        final LeafRefContextBuilder rootBuilder = new LeafRefContextBuilder(
-                schemaContext.getQName(), schemaContext.getPath(),
-                schemaContext);
+        final LeafRefContextBuilder rootBuilder = new LeafRefContextBuilder(schemaContext.getQName(),
+            schemaContext.getPath(), schemaContext);
 
         final Set<Module> modules = schemaContext.getModules();
         for (final Module module : modules) {
index 3ddb01e5fa842da5775ce5cb791e27bfc7c30f9f..6adf7456a6a0d73b779cae580c699ec5d1227aa3 100644 (file)
@@ -10,20 +10,21 @@ package org.opendaylight.yangtools.yang.data.impl.leafref;
 public class LeafRefDataValidationFailedException extends Exception {
 
     private static final long serialVersionUID = 1L;
-    private int errorsCount = 1;
 
-    public LeafRefDataValidationFailedException(String message) {
-        super(message);
-    }
+    private final int errorsCount;
 
-    public LeafRefDataValidationFailedException(String message, int errorsCount) {
+    public LeafRefDataValidationFailedException(final String message, final int errorsCount) {
         super(message);
         this.errorsCount = errorsCount;
     }
 
-    public LeafRefDataValidationFailedException(String message,
-            final Throwable cause) {
+    public LeafRefDataValidationFailedException(final String message) {
+        this(message, 1);
+    }
+
+    public LeafRefDataValidationFailedException(final String message, final Throwable cause) {
         super(message, cause);
+        errorsCount = 1;
     }
 
     public int getValidationsErrorsCount() {
index 988de8e8874ee9fd7ad3140e16517a21a234fc3f..ae0aae7612464da5ca6df433f08ea0bc799d426c 100644 (file)
@@ -62,8 +62,8 @@ public abstract class LeafRefPath implements Immutable {
     }
 
     @SuppressWarnings("rawtypes")
-    private static final AtomicReferenceFieldUpdater<LeafRefPath, ImmutableList> LEGACYPATH_UPDATER = AtomicReferenceFieldUpdater
-            .newUpdater(LeafRefPath.class, ImmutableList.class, "legacyPath");
+    private static final AtomicReferenceFieldUpdater<LeafRefPath, ImmutableList> LEGACYPATH_UPDATER =
+        AtomicReferenceFieldUpdater.newUpdater(LeafRefPath.class, ImmutableList.class, "legacyPath");
 
     /**
      * Shared instance of the conceptual root schema node.
@@ -110,12 +110,12 @@ public abstract class LeafRefPath implements Immutable {
         this.parent = parent;
         this.qname = qname;
 
-        int h = Objects.hashCode(parent);
+        int hc = Objects.hashCode(parent);
         if (qname != null) {
-            h = h * 31 + qname.hashCode();
+            hc = hc * 31 + qname.hashCode();
         }
 
-        hash = h;
+        hash = hc;
     }
 
     /**
@@ -313,16 +313,13 @@ public abstract class LeafRefPath implements Immutable {
     public String toString() {
         StringBuilder sb = new StringBuilder();
 
-        Iterable<QNameWithPredicate> pathFromRoot = this.getPathFromRoot();
-
         sb.append(isAbsolute() ? "Absolute path:" : "Relative path:");
 
-        for (QNameWithPredicate qName : pathFromRoot) {
-            sb.append('/').append(qName);
+        for (QNameWithPredicate qname : getPathFromRoot()) {
+            sb.append('/').append(qname);
         }
 
         return sb.toString();
-
     }
 
     // @Override
index bbdbb35886a947fe95c0c8c0f2f7f99075004215..ff987709d600ddb9b1a47eb8d4d730a28606315e 100644 (file)
@@ -22,11 +22,12 @@ class LeafRefPathErrorListener extends BaseErrorListener {
     private final List<LeafRefPathSyntaxErrorException> exceptions = new ArrayList<>(1);
     private final Module module;
 
-    public LeafRefPathErrorListener(final Module module) {
+    LeafRefPathErrorListener(final Module module) {
         this.module = module;
     }
 
     @Override
+    @SuppressWarnings("checkstyle:parameterName")
     public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
             final int charPositionInLine, final String msg, final RecognitionException e) {
         LOG.debug("Syntax error in module {} at {}:{}: {}", module.getName(), line, charPositionInLine, msg, e);
index e5552c55ea599fb68a48077c2dfeafc4fc61c286..f7f316b752536a8c9c5f97921f86e87efcfd03ec 100644 (file)
@@ -22,27 +22,26 @@ final class LeafRefPathParserImpl {
     private final Module module;
     private final SchemaNode node;
 
-     public LeafRefPathParserImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
+    LeafRefPathParserImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
         this.schemaContext = schemaContext;
         this.module = currentModule;
         this.node = currentNode;
     }
 
-    public LeafRefPath parseLeafRefPathSourceToSchemaPath(final InputStream stream) throws IOException, LeafRefYangSyntaxErrorException {
-
+    public LeafRefPath parseLeafRefPathSourceToSchemaPath(final InputStream stream) throws IOException,
+            LeafRefYangSyntaxErrorException {
         final Path_argContext pathCtx = parseLeafRefPathSource(stream);
 
         final ParseTreeWalker walker = new ParseTreeWalker();
-        final LeafRefPathParserListenerImpl leafRefPathParserListenerImpl = new LeafRefPathParserListenerImpl(schemaContext, module, node);
-        walker.walk(leafRefPathParserListenerImpl,pathCtx);
-
-        final LeafRefPath leafRefPath = leafRefPathParserListenerImpl.getLeafRefPath();
+        final LeafRefPathParserListenerImpl leafRefPathParserListenerImpl = new LeafRefPathParserListenerImpl(
+            schemaContext, module, node);
+        walker.walk(leafRefPathParserListenerImpl, pathCtx);
 
-        return leafRefPath;
+        return leafRefPathParserListenerImpl.getLeafRefPath();
     }
 
-
-    private Path_argContext parseLeafRefPathSource(final InputStream stream) throws IOException, LeafRefYangSyntaxErrorException {
+    private Path_argContext parseLeafRefPathSource(final InputStream stream) throws IOException,
+            LeafRefYangSyntaxErrorException {
         final LeafRefPathLexer lexer = new LeafRefPathLexer(CharStreams.fromStream(stream));
         final CommonTokenStream tokens = new CommonTokenStream(lexer);
         final LeafRefPathParser parser = new LeafRefPathParser(tokens);
@@ -53,8 +52,6 @@ final class LeafRefPathParserImpl {
 
         final Path_argContext result = parser.path_arg();
         errorListener.validate();
-
         return result;
     }
-
 }
index b94c79499e34d236a2a3ee542bde54f470dc23cd..e3a936e5b92df672a476125eb28034bcbb69c397 100644 (file)
@@ -30,12 +30,12 @@ import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 
-final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener{
+final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener {
 
     private final List<QNameWithPredicateBuilder> leafRefPathQnameList = new ArrayList<>();
     private final SchemaContext schemaContext;
     private final Module module;
-  //FIXME use for identifier path completion
+    // FIXME: use for identifier path completion
     private final SchemaNode node;
 
     private ParsingState currentParsingState = ParsingState.LEAF_REF_PATH;
@@ -51,15 +51,16 @@ final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener{
         LEAF_REF_PATH, PATH_PREDICATE, PREDICATE_PATH_EQUALITY_EXPR, PATH_KEY_EXPR
     }
 
-    public LeafRefPathParserListenerImpl(final SchemaContext schemaContext, final Module currentModule, final SchemaNode currentNode) {
-       this.schemaContext = schemaContext;
-       this.module = currentModule;
-       this.node = currentNode;
+    LeafRefPathParserListenerImpl(final SchemaContext schemaContext, final Module currentModule,
+            final SchemaNode currentNode) {
+        this.schemaContext = schemaContext;
+        this.module = currentModule;
+        this.node = currentNode;
     }
 
     @Override
     public void enterPath_predicate(final Path_predicateContext ctx) {
-        currentParsingState=ParsingState.PATH_PREDICATE;
+        currentParsingState = ParsingState.PATH_PREDICATE;
         currentPredicate = new QNamePredicateBuilder();
     }
 
@@ -67,13 +68,13 @@ final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener{
     public void exitPath_predicate(final Path_predicateContext ctx) {
         currentLeafRefPathQName.addQNamePredicate(currentPredicate.build());
         currentPredicate = null;
-        currentParsingState=ParsingState.LEAF_REF_PATH;
+        currentParsingState = ParsingState.LEAF_REF_PATH;
     }
 
 
     @Override
     public void enterRel_path_keyexpr(final Rel_path_keyexprContext ctx) {
-        currentParsingState=ParsingState.PATH_KEY_EXPR;
+        currentParsingState = ParsingState.PATH_KEY_EXPR;
 
         final List<TerminalNode> dots = ctx.DOTS();
         predicatePathKeyQnameList = new ArrayList<>(dots.size());
@@ -88,7 +89,7 @@ final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener{
             QNameWithPredicateBuilder::build), false);
         currentPredicate.setPathKeyExpression(pathKeyExpression);
 
-        currentParsingState=ParsingState.PREDICATE_PATH_EQUALITY_EXPR;
+        currentParsingState = ParsingState.PREDICATE_PATH_EQUALITY_EXPR;
     }
 
     @Override
@@ -163,7 +164,8 @@ final class LeafRefPathParserListenerImpl extends LeafRefPathParserBaseListener{
 
     private URI getNamespaceForImportPrefix(final String prefix) {
         final ModuleImport moduleImport = getModuleImport(prefix);
-        final Module findedModule = schemaContext.findModuleByName(moduleImport.getModuleName(), moduleImport.getRevision());
+        final Module findedModule = schemaContext.findModuleByName(moduleImport.getModuleName(),
+            moduleImport.getRevision());
 
         return findedModule.getNamespace();
     }
index 01e68ac6ad4ba44ee11a949c4847cee30edb5668..d82af1b777aa2a4344836b252566ef97dcbe909c 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.leafref;
 
-public class LeafRefPathSyntaxErrorException extends LeafRefYangSyntaxErrorException{
+public class LeafRefPathSyntaxErrorException extends LeafRefYangSyntaxErrorException {
 
     private static final long serialVersionUID = 1L;
 
index 58a6f1538a3a94228efca49203dbc10b7e343fdb..8f41856bd88ee656ed1372feea4412b6927457de 100644 (file)
@@ -26,6 +26,8 @@ public final class LeafRefUtils {
     }
 
     /**
+     * Create an absolute leafref path.
+     *
      * @param leafRefPath leafRefPath
      * @param contextNodeSchemaPath contextNodeSchemaPath
      * @param module module
@@ -41,11 +43,7 @@ public final class LeafRefUtils {
 
         final Deque<QNameWithPredicate> absoluteLeafRefTargetPathList = schemaPathToXPathQNames(
                 contextNodeSchemaPath, module);
-
-        final Iterable<QNameWithPredicate> leafRefTargetPathFromRoot = leafRefPath
-                .getPathFromRoot();
-        final Iterator<QNameWithPredicate> leafRefTgtPathFromRootIterator = leafRefTargetPathFromRoot
-                .iterator();
+        final Iterator<QNameWithPredicate> leafRefTgtPathFromRootIterator = leafRefPath.getPathFromRoot().iterator();
 
         while (leafRefTgtPathFromRootIterator.hasNext()) {
             final QNameWithPredicate qname = leafRefTgtPathFromRootIterator.next();
@@ -59,11 +57,6 @@ public final class LeafRefUtils {
         return LeafRefPath.create(absoluteLeafRefTargetPathList, true);
     }
 
-    /**
-     * @param currentNodePath
-     * @param module
-     * @param absoluteLeafRefTargetPathList
-     */
     private static Deque<QNameWithPredicate> schemaPathToXPathQNames(
             final SchemaPath nodePath, final Module module) {
 
@@ -114,11 +107,7 @@ public final class LeafRefUtils {
         return xpath;
     }
 
-    public static LeafRefPath schemaPathToLeafRefPath(final SchemaPath nodePath,
-            final Module module) {
-        final Deque<QNameWithPredicate> xpathQNames = schemaPathToXPathQNames(
-                nodePath, module);
-        return LeafRefPath.create(xpathQNames, true);
+    public static LeafRefPath schemaPathToLeafRefPath(final SchemaPath nodePath, final Module module) {
+        return LeafRefPath.create(schemaPathToXPathQNames(nodePath, module), true);
     }
-
 }
index 23e19db5546a9bd517088a6956940df14649841f..a573e6a8716226ceb376076f7c135d2e817e0594 100644 (file)
@@ -155,8 +155,9 @@ public class LeafRefValidatation {
         return childReferencedByCtx;
     }
 
-    private void validateNodeData(final NormalizedNode<?, ?> node, final LeafRefContext referencedByCtx, final
-            LeafRefContext referencingCtx, final ModificationType modificationType, final YangInstanceIdentifier current) {
+    private void validateNodeData(final NormalizedNode<?, ?> node, final LeafRefContext referencedByCtx,
+            final LeafRefContext referencingCtx, final ModificationType modificationType,
+            final YangInstanceIdentifier current) {
 
         if (node instanceof LeafNode) {
             final LeafNode<?> leaf = (LeafNode<?>) node;
@@ -218,8 +219,8 @@ public class LeafRefValidatation {
         } else if (node instanceof DataContainerNode) {
             final DataContainerNode<?> dataContainerNode = (DataContainerNode<?>) node;
 
-            for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : dataContainerNode.getValue()) {
-                final QName qname = dataContainerChild.getNodeType();
+            for (final DataContainerChild<? extends PathArgument, ?> child : dataContainerNode.getValue()) {
+                final QName qname = child.getNodeType();
 
                 final LeafRefContext childReferencedByCtx;
                 if (referencedByCtx != null) {
@@ -237,8 +238,8 @@ public class LeafRefValidatation {
 
                 if (childReferencedByCtx != null || childReferencingCtx != null) {
                     final YangInstanceIdentifier childYangInstanceIdentifier = current
-                            .node(dataContainerChild.getIdentifier());
-                    validateNodeData(dataContainerChild, childReferencedByCtx,
+                            .node(child.getIdentifier());
+                    validateNodeData(child, childReferencedByCtx,
                             childReferencingCtx, modificationType, childYangInstanceIdentifier);
                 }
             }
@@ -265,11 +266,8 @@ public class LeafRefValidatation {
                     }
 
                     if (childReferencedByCtx != null || childReferencingCtx != null) {
-                        final YangInstanceIdentifier mapEntryNodeYangInstanceIdentifier = mapEntryYangInstanceIdentifier
-                                .node(mapEntryNode.getIdentifier());
-                        validateNodeData(mapEntryNode, childReferencedByCtx,
-                                childReferencingCtx, modificationType,
-                                mapEntryNodeYangInstanceIdentifier);
+                        validateNodeData(mapEntryNode, childReferencedByCtx, childReferencingCtx, modificationType,
+                                mapEntryYangInstanceIdentifier.node(mapEntryNode.getIdentifier()));
                     }
                 }
             }
@@ -353,13 +351,13 @@ public class LeafRefValidatation {
                 final Set<?> leafRefValuesSet = entry.getValue();
                 for (final Object leafRefsValue : leafRefValuesSet) {
                     if (leafRefTargetNodeValues != null && !leafRefTargetNodeValues.contains(leafRefsValue)) {
-                        LOG.debug("Invalid leafref value [{}] allowed values {} by validation of leafref TARGET node:" +
-                                {} path of invalid LEAFREF node: {} leafRef target path: {} {}", leafRefsValue,
+                        LOG.debug("Invalid leafref value [{}] allowed values {} by validation of leafref TARGET node: "
+                                + "{} path of invalid LEAFREF node: {} leafRef target path: {} {}", leafRefsValue,
                                 leafRefTargetNodeValues, leaf.getNodeType(), leafRefContext.getCurrentNodePath(),
                                 leafRefContext.getAbsoluteLeafRefTargetPath(), FAILED);
-                        errorsMessages.add(String.format("Invalid leafref value [%s] allowed values %s by validation " +
-                                        "of  leafref TARGET node: %s path of invalid LEAFREF node: %s leafRef target " +
-                                        "path: %s %s", leafRefsValue, leafRefTargetNodeValues, leaf.getNodeType(),
+                        errorsMessages.add(String.format("Invalid leafref value [%s] allowed values %s by validation "
+                                        + "of leafref TARGET node: %s path of invalid LEAFREF node: %s leafRef target "
+                                        "path: %s %s", leafRefsValue, leafRefTargetNodeValues, leaf.getNodeType(),
                                 leafRefContext.getCurrentNodePath(), leafRefContext.getAbsoluteLeafRefTargetPath(),
                                 FAILED));
                     } else {
@@ -368,8 +366,8 @@ public class LeafRefValidatation {
                 }
             }
         } else if (leafRefsValues != null) {
-            LOG.debug("Operation [{}] validate data of leafref TARGET node: name[{}] = value[{}] -> SKIP: Already validated",
-                    modificationType, referencedByCtx.getNodeName(), leaf.getValue());
+            LOG.debug("Operation [{}] validate data of leafref TARGET node: name[{}] = value[{}] "
+                    + "-> SKIP: Already validated", modificationType, referencedByCtx.getNodeName(), leaf.getValue());
         }
     }
 
@@ -386,8 +384,8 @@ public class LeafRefValidatation {
                     modificationType, referencingCtx.getNodeName(), leaf.getValue(), FAILED);
             LOG.debug("Invalid leafref value [{}] allowed values {} of LEAFREF node: {} leafRef target path: {}",
                     leaf.getValue(), values, leaf.getNodeType(), referencingCtx.getAbsoluteLeafRefTargetPath());
-            errorsMessages.add(String.format("Invalid leafref value [%s] allowed values %s of LEAFREF node: %s " +
-                            "leafRef  target path: %s", leaf.getValue(), values, leaf.getNodeType(), referencingCtx
+            errorsMessages.add(String.format("Invalid leafref value [%s] allowed values %s of LEAFREF node: %s "
+                            + "leafRef target path: %s", leaf.getValue(), values, leaf.getNodeType(), referencingCtx
                     .getAbsoluteLeafRefTargetPath()));
         } else {
             LOG.debug("Operation [{}] validate data of LEAFREF node: name[{}] = value[{}] {}", modificationType,
@@ -396,7 +394,8 @@ public class LeafRefValidatation {
     }
 
     private void addValues(final Set<Object> values, final Optional<? extends NormalizedNode<?, ?>> optDataNode,
-            final Iterable<QNameWithPredicate> path, final YangInstanceIdentifier current, final QNameWithPredicate previousQName) {
+            final Iterable<QNameWithPredicate> path, final YangInstanceIdentifier current,
+            final QNameWithPredicate previousQName) {
 
         if (!optDataNode.isPresent()) {
             return;
@@ -496,7 +495,8 @@ public class LeafRefValidatation {
         return choiceNodes;
     }
 
-    private static boolean isMatchingPredicate(final MapEntryNode mapEntryNode, final Map<QName, Set<?>> allowedKeyValues) {
+    private static boolean isMatchingPredicate(final MapEntryNode mapEntryNode,
+            final Map<QName, Set<?>> allowedKeyValues) {
         for (final Entry<QName, Object> entryKeyValue : mapEntryNode.getIdentifier().getKeyValues().entrySet()) {
             final Set<?> allowedValues = allowedKeyValues.get(entryKeyValue.getKey());
             if (allowedValues != null && !allowedValues.contains(entryKeyValue.getValue())) {
@@ -511,13 +511,13 @@ public class LeafRefValidatation {
             final YangInstanceIdentifier current) {
 
         final Optional<NormalizedNode<?, ?>> parent = findParentNode(tree.getRootNode().getDataAfter(), current);
-
         final Iterable<QNameWithPredicate> predicatePathExpr = predicatePathKeyExpression.getPathFromRoot();
         final Iterable<QNameWithPredicate> predicatePath = nextLevel(predicatePathExpr);
 
         final Set<Object> values = new HashSet<>();
+        // FIXME: this null check does not look right
         if (parent != null) {
-            addValues(values, parent, predicatePath, null,QNameWithPredicate.ROOT);
+            addValues(values, parent, predicatePath, null, QNameWithPredicate.ROOT);
         }
 
         return values;
@@ -541,4 +541,4 @@ public class LeafRefValidatation {
     private static Iterable<QNameWithPredicate> nextLevel(final Iterable<QNameWithPredicate> path) {
         return Iterables.skip(path, 1);
     }
-}
\ No newline at end of file
+}
index 778a851d72710d5b112d92045e22cb93272a8620..90d1bd63df58bc6bc054969bbafeddb2f1e70c12 100644 (file)
@@ -7,17 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.leafref;
 
+import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.common.QName;
 
-class QNamePredicateBuilder {
+class QNamePredicateBuilder implements Builder<QNamePredicate> {
 
     private QName identifier;
     private LeafRefPath pathKeyExpression;
 
-    public QNamePredicateBuilder() {
+    QNamePredicateBuilder() {
     }
 
-    public QNamePredicateBuilder(final QName identifier, final LeafRefPath pathKeyExpression) {
+    QNamePredicateBuilder(final QName identifier, final LeafRefPath pathKeyExpression) {
         this.identifier = identifier;
         this.pathKeyExpression = pathKeyExpression;
     }
@@ -38,6 +39,7 @@ class QNamePredicateBuilder {
         this.pathKeyExpression = pathKeyExpression;
     }
 
+    @Override
     public QNamePredicate build() {
         return new QNamePredicateImpl(identifier, pathKeyExpression);
     }
@@ -50,11 +52,8 @@ class QNamePredicateBuilder {
         sb.append(identifier);
         sb.append("=current()");
 
-        final Iterable<QNameWithPredicate> pathFromRoot = pathKeyExpression
-                .getPathFromRoot();
-
-        for (final QNameWithPredicate qName : pathFromRoot) {
-            sb.append('/').append(qName);
+        for (final QNameWithPredicate qname : pathKeyExpression.getPathFromRoot()) {
+            sb.append('/').append(qname);
         }
 
         sb.append(']');
index 5703baee85036f4fe81efc33fa811a003a565e28..14e99cde885ed5fd7339593130ed5f8de798c842 100644 (file)
@@ -13,14 +13,15 @@ import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 
 class QNamePredicateImpl implements Immutable, Serializable, QNamePredicate {
-
     private static final long serialVersionUID = 1L;
+
     private final QName identifier;
     private final LeafRefPath pathKeyExpression;
 
-    public QNamePredicateImpl(final QName identifier, final LeafRefPath pathKeyExpression) {
+    QNamePredicateImpl(final QName identifier, final LeafRefPath pathKeyExpression) {
         this.identifier = Preconditions.checkNotNull(identifier, "QNamePredicate: identifier should not be null");
-        this.pathKeyExpression = Preconditions.checkNotNull(pathKeyExpression, "QNamePredicate: pathKeyExpression should not be null");
+        this.pathKeyExpression = Preconditions.checkNotNull(pathKeyExpression,
+            "QNamePredicate: pathKeyExpression should not be null");
     }
 
     @Override
@@ -36,20 +37,12 @@ class QNamePredicateImpl implements Immutable, Serializable, QNamePredicate {
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder();
-        sb.append('[');
-
-        sb.append(identifier);
-        sb.append("=current()");
+        sb.append('[').append(identifier).append("=current()");
 
-        final Iterable<QNameWithPredicate> pathFromRoot = pathKeyExpression
-                .getPathFromRoot();
-
-        for (final QNameWithPredicate qName : pathFromRoot) {
-            sb.append('/').append(qName);
+        for (final QNameWithPredicate qname : pathKeyExpression.getPathFromRoot()) {
+            sb.append('/').append(qname);
         }
 
-        sb.append(']');
-        return sb.toString();
+        return sb.append(']').toString();
     }
-
 }
index bef27ff45aec3fc53288d7929b41953e9a31792c..147ff5db9c60d9fae19532b9344ea397eab6f64c 100644 (file)
@@ -10,27 +10,28 @@ package org.opendaylight.yangtools.yang.data.impl.leafref;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 
-class QNameWithPredicateBuilder {
+class QNameWithPredicateBuilder implements Builder<QNameWithPredicate> {
 
     private final List<QNamePredicate> qnamePredicates = new ArrayList<>();
     private QNameModule moduleQname;
     private String localName;
 
-    public static final QNameWithPredicateBuilder UP_PARENT_BUILDER = new QNameWithPredicateBuilder(
-            null, "..") {
+    static final QNameWithPredicateBuilder UP_PARENT_BUILDER = new QNameWithPredicateBuilder(null, "..") {
         @Override
         public QNameWithPredicate build() {
             return QNameWithPredicate.UP_PARENT;
         }
     };
 
-    public QNameWithPredicateBuilder(final QNameModule moduleQname, final String localName) {
+    QNameWithPredicateBuilder(final QNameModule moduleQname, final String localName) {
         this.moduleQname = moduleQname;
         this.localName = localName;
     }
 
+    @Override
     public QNameWithPredicate build() {
         final QNameWithPredicateImpl qNameWithPredicateImpl = new QNameWithPredicateImpl(
                 moduleQname, localName, qnamePredicates);
index b9d00813b42ced9a3c555121fac52b9afee02a79..9317ad994207981946eb28801605da395bf0fb7d 100644 (file)
@@ -15,8 +15,7 @@ import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 
-final class QNameWithPredicateImpl implements Immutable, Serializable,
-        QNameWithPredicate {
+final class QNameWithPredicateImpl implements Immutable, Serializable, QNameWithPredicate {
 
     private static final long serialVersionUID = 1L;
 
@@ -24,7 +23,7 @@ final class QNameWithPredicateImpl implements Immutable, Serializable,
     private final QNameModule moduleQname;
     private final String localName;
 
-    public QNameWithPredicateImpl(final QNameModule moduleQname, final String localName,
+    QNameWithPredicateImpl(final QNameModule moduleQname, final String localName,
             final List<QNamePredicate> qnamePredicates) {
         this.moduleQname = moduleQname;
         this.localName = localName;
@@ -89,5 +88,4 @@ final class QNameWithPredicateImpl implements Immutable, Serializable,
 
         return sb.toString();
     }
-
 }
index e930de63c84942489019f4ed1e337ec84570b1da..6b739eee0aaf4f7e725e9fe78254deef85aab45c 100644 (file)
@@ -102,11 +102,7 @@ public final class Builders {
         return ImmutableYangModeledAnyXmlNodeBuilder.create(schema);
     }
 
-    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder() {
-        return ImmutableLeafSetNodeBuilder.create();
-    }
-
-    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>>  orderedLeafSetBuilder() {
+    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> orderedLeafSetBuilder() {
         return ImmutableOrderedLeafSetNodeBuilder.create();
     }
 
@@ -114,6 +110,10 @@ public final class Builders {
         return ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(schema);
     }
 
+    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder() {
+        return ImmutableLeafSetNodeBuilder.create();
+    }
+
     public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafSetNode<T> node) {
         return ImmutableLeafSetNodeBuilder.create(node);
     }
@@ -122,7 +122,8 @@ public final class Builders {
         return ImmutableLeafSetNodeSchemaAwareBuilder.create(schema);
     }
 
-    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafListSchemaNode schema, final LeafSetNode<T> node) {
+    public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder(final LeafListSchemaNode schema,
+            final LeafSetNode<T> node) {
         return ImmutableLeafSetNodeSchemaAwareBuilder.create(schema, node);
     }
 
@@ -130,7 +131,8 @@ public final class Builders {
         return ImmutableContainerNodeBuilder.create();
     }
 
-    public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder(final ContainerNode node) {
+    public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> containerBuilder(
+            final ContainerNode node) {
         return ImmutableContainerNodeBuilder.create(node);
     }
 
@@ -153,10 +155,6 @@ public final class Builders {
         return ImmutableMapEntryNodeSchemaAwareBuilder.create(schema);
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder() {
-        return ImmutableMapNodeBuilder.create();
-    }
-
     public static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> orderedMapBuilder() {
         return ImmutableOrderedMapNodeBuilder.create();
     }
@@ -169,6 +167,10 @@ public final class Builders {
         return ImmutableUnkeyedListNodeBuilder.create();
     }
 
+    public static CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder() {
+        return ImmutableMapNodeBuilder.create();
+    }
+
     public static CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder(final MapNode node) {
         return ImmutableMapNodeBuilder.create(node);
     }
@@ -177,7 +179,8 @@ public final class Builders {
         return ImmutableMapNodeSchemaAwareBuilder.create(schema);
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder(final ListSchemaNode schema, final MapNode node) {
+    public static CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder(final ListSchemaNode schema,
+            final MapNode node) {
         return ImmutableMapNodeSchemaAwareBuilder.create(schema, node);
     }
 
@@ -185,7 +188,8 @@ public final class Builders {
         return ImmutableAugmentationNodeBuilder.create();
     }
 
-    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> augmentationBuilder(final AugmentationSchema schema) {
+    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> augmentationBuilder(
+            final AugmentationSchema schema) {
         return ImmutableAugmentationNodeSchemaAwareBuilder.create(schema);
     }
 
@@ -200,5 +204,4 @@ public final class Builders {
     public static DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> unkeyedListEntryBuilder() {
         return ImmutableUnkeyedListEntryNodeBuilder.create();
     }
-
 }
index a7f9b79dd471a629c87e0df354a541cfa0cad373..c360b74f54f9fdaa21cee35dbfaba155fd5d7235 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import java.util.Map;
+import java.util.Map.Entry;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -46,7 +46,7 @@ public final class ImmutableNodes {
     }
 
     /**
-     * Construct immutable leaf node
+     * Construct immutable leaf node.
      *
      * @param name Identifier of leaf node
      * @param value Value of leaf node
@@ -61,7 +61,7 @@ public final class ImmutableNodes {
     }
 
     /**
-     * Construct immutable leaf node
+     * Construct immutable leaf node.
      *
      * @param name QName which will be used as node identifier
      * @param value Value of leaf node.
@@ -72,20 +72,21 @@ public final class ImmutableNodes {
         return leafNode(NodeIdentifier.create(name), value);
     }
 
-    public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder(final QName nodeName, final QName keyName, final Object keyValue) {
+    public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder(
+            final QName nodeName, final QName keyName, final Object keyValue) {
         return ImmutableMapEntryNodeBuilder.create()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(nodeName, keyName, keyValue))
                 .withChild(leafNode(keyName, keyValue));
     }
 
-    public static MapEntryNode mapEntry(final QName nodeName,final QName keyName,final Object keyValue) {
-        return mapEntryBuilder(nodeName, keyName, keyValue).build();
-    }
-
     public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder() {
         return ImmutableMapEntryNodeBuilder.create();
     }
 
+    public static MapEntryNode mapEntry(final QName nodeName,final QName keyName,final Object keyValue) {
+        return mapEntryBuilder(nodeName, keyName, keyValue).build();
+    }
+
     public static ContainerNode containerNode(final QName name) {
         return ImmutableContainerNodeBuilder.create().withNodeIdentifier(NodeIdentifier.create(name)).build();
     }
@@ -95,7 +96,7 @@ public final class ImmutableNodes {
     }
 
     /**
-     * Convert YangInstanceIdentifier into a normalized node structure
+     * Convert YangInstanceIdentifier into a normalized node structure.
      *
      * @param ctx schema context to used during serialization
      * @param id instance identifier to convert to node structure starting from root
@@ -106,33 +107,41 @@ public final class ImmutableNodes {
     }
 
     /**
-     * Convert YangInstanceIdentifier into a normalized node structure
+     * Convert YangInstanceIdentifier into a normalized node structure.
      *
      * @param ctx schema context to used during serialization
      * @param id instance identifier to convert to node structure starting from root
-     * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided instance Id
+     * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided
+     *                       instance identifier
      * @return serialized normalized node for provided instance Id with overridden last child.
      */
-    public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id, final NormalizedNode<?, ?> deepestElement) {
+    public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id,
+            final NormalizedNode<?, ?> deepestElement) {
         return fromInstanceId(ctx, id, Optional.of(deepestElement), Optional.absent());
     }
 
     /**
-     * Convert YangInstanceIdentifier into a normalized node structure
+     * Convert YangInstanceIdentifier into a normalized node structure.
      *
      * @param ctx schema context to used during serialization
      * @param id instance identifier to convert to node structure starting from root
-     * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided instance Id
-     * @param operation modify operation attribute to be added to the deepest child. QName is the operation attribute key and ModifyAction is the value.
-     * @return serialized normalized node for provided instance Id with (optionally) overridden last child and (optionally) marked with specific operation attribute.
+     * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided
+     *                       instance identifier
+     * @param operation modify operation attribute to be added to the deepest child. QName is the operation attribute
+     *                  key and ModifyAction is the value.
+     * @return serialized normalized node for provided instance Id with (optionally) overridden last child
+     *         and (optionally) marked with specific operation attribute.
      */
-    public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id, final Optional<NormalizedNode<?, ?>> deepestElement, final Optional<Map.Entry<QName, ModifyAction>> operation) {
+    public static NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id,
+            final Optional<NormalizedNode<?, ?>> deepestElement, final Optional<Entry<QName, ModifyAction>> operation) {
         Preconditions.checkNotNull(ctx);
         Preconditions.checkNotNull(id);
         final YangInstanceIdentifier.PathArgument topLevelElement = id.getPathArguments().get(0);
         final DataSchemaNode dataChildByName = ctx.getDataChildByName(topLevelElement.getNodeType());
-        Preconditions.checkNotNull(dataChildByName, "Cannot find %s node in schema context. Instance identifier has to start from root", topLevelElement);
-        final InstanceIdToNodes<?> instanceIdToNodes = InstanceIdToNodes.fromSchemaAndQNameChecked(ctx, topLevelElement.getNodeType());
+        Preconditions.checkNotNull(dataChildByName,
+            "Cannot find %s node in schema context. Instance identifier has to start from root", topLevelElement);
+        final InstanceIdToNodes<?> instanceIdToNodes = InstanceIdToNodes.fromSchemaAndQNameChecked(ctx,
+            topLevelElement.getNodeType());
         return instanceIdToNodes.create(id, deepestElement, operation);
     }
 }
index e20a481296759ec9b5c375ce38f703b17d3d1313..a0cafec35d2cd3d82cc4b89755d906a82c634e4f 100644 (file)
@@ -55,17 +55,16 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.YangModeledAnyXmlSchemaNode;
 
 /**
+ * Implementation of {@link NormalizedNodeStreamWriter}, which constructs immutable instances of
+ * {@link NormalizedNode}s.
  *
- * Implementation of {@link NormalizedNodeStreamWriter}, which constructs
- * immutable instances of {@link NormalizedNode}s.
  * <p>
- * This writer supports two modes of behaviour one is using {@link #from(NormalizedNodeResult)}
- * where resulting NormalizedNode will be stored in supplied result object.
- *
- * Other mode of operation is using {@link #from(NormalizedNodeContainerBuilder)},
- * where all created nodes will be written to this builder.
- *
+ * This writer supports two modes of behaviour one is using {@link #from(NormalizedNodeResult)} where resulting
+ * NormalizedNode will be stored in supplied result object.
  *
+ * <p>
+ * Other mode of operation is using {@link #from(NormalizedNodeContainerBuilder)}, where all created nodes will be
+ * written to this builder.
  */
 public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStreamWriter {
 
@@ -83,12 +82,12 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     }
 
     /**
-     * Creates a {@link NormalizedNodeStreamWriter} which creates instances of supplied
-     * {@link NormalizedNode}s and writes them to supplied builder as child nodes.
+     * Creates a {@link NormalizedNodeStreamWriter} which creates instances of supplied {@link NormalizedNode}s
+     * and writes them to supplied builder as child nodes.
+     *
      * <p>
-     * Type of supplied {@link NormalizedNodeContainerBuilder} affects,
-     * which events could be emitted in order to ensure proper construction of
-     * data.
+     * Type of supplied {@link NormalizedNodeContainerBuilder} affects, which events could be emitted in order
+     * to ensure proper construction of data.
      *
      * @param builder Builder to which data will be written.
      * @return {@link NormalizedNodeStreamWriter} which writes data
@@ -98,19 +97,19 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     }
 
     /**
-     * Creates a {@link NormalizedNodeStreamWriter} which creates one instance of top
-     * level {@link NormalizedNode} (type of NormalizedNode) is determined by first
-     * start event.
+     * Creates a {@link NormalizedNodeStreamWriter} which creates one instance of top-level {@link NormalizedNode}
+     * (type of NormalizedNode) is determined by first start event.
+     *
      * <p>
-     * Result is built when {@link #endNode()} associated with that start event
-     * is emitted.
+     * Result is built when {@link #endNode()} associated with that start event is emitted.
+     *
      * <p>
-     * Writer properly creates also nested {@link NormalizedNode} instances,
-     * if their are supported inside the scope of first event.
+     * Writer properly creates also nested {@link NormalizedNode} instances, if their are supported inside the scope
+     * of the first event.
+     *
      * <p>
-     * This method is useful for clients, which knows there will be one
-     * top level node written, but does not know which type of {@link NormalizedNode}
-     * will be written.
+     * This method is useful for clients, which knows there will be one top-level node written, but does not know which
+     * type of {@link NormalizedNode} will be written.
      *
      * @param result {@link NormalizedNodeResult} object which will hold result value.
      * @return {@link NormalizedNodeStreamWriter} which will write item to supplied result holder.
@@ -170,9 +169,9 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     @Override
     public void startLeafSet(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
-        final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = UNKNOWN_SIZE == childSizeHint ?
-                InterningLeafSetNodeBuilder.create(nextSchema) :
-                    InterningLeafSetNodeBuilder.create(nextSchema, childSizeHint);
+        final ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = UNKNOWN_SIZE == childSizeHint
+                ? InterningLeafSetNodeBuilder.create(nextSchema)
+                        : InterningLeafSetNodeBuilder.create(nextSchema, childSizeHint);
         builder.withNodeIdentifier(name);
         enter(builder);
     }
@@ -181,11 +180,13 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void leafSetEntryNode(final QName name, final Object value) {
         if (getCurrent() instanceof ImmutableOrderedLeafSetNodeBuilder) {
             @SuppressWarnings("unchecked")
-            ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = ((ImmutableOrderedLeafSetNodeBuilder<Object>) getCurrent());
+            ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder =
+                (ImmutableOrderedLeafSetNodeBuilder<Object>) getCurrent();
             builder.withChildValue(value);
         } else if (getCurrent() instanceof ImmutableLeafSetNodeBuilder) {
             @SuppressWarnings("unchecked")
-            ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder = ((ImmutableLeafSetNodeBuilder<Object>) getCurrent());
+            ListNodeBuilder<Object, LeafSetEntryNode<Object>> builder =
+                (ImmutableLeafSetNodeBuilder<Object>) getCurrent();
             builder.withChildValue(value);
         } else {
             throw new IllegalArgumentException("LeafSetEntryNode is not valid for parent " + getCurrent());
@@ -217,8 +218,9 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void startContainerNode(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
 
-        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableContainerNodeBuilder.create() : ImmutableContainerNodeBuilder.create(childSizeHint);
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder =
+                UNKNOWN_SIZE == childSizeHint ? ImmutableContainerNodeBuilder.create()
+                        : ImmutableContainerNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
@@ -228,8 +230,10 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
 
         Preconditions.checkArgument(nextSchema instanceof YangModeledAnyXmlSchemaNode,
                 "Schema of this node should be instance of YangModeledAnyXmlSchemaNode");
-        final DataContainerNodeAttrBuilder<NodeIdentifier, YangModeledAnyXmlNode> builder = UNKNOWN_SIZE == childSizeHint ? ImmutableYangModeledAnyXmlNodeBuilder
-                .create((YangModeledAnyXmlSchemaNode) nextSchema) : ImmutableYangModeledAnyXmlNodeBuilder.create(
+        final DataContainerNodeAttrBuilder<NodeIdentifier, YangModeledAnyXmlNode> builder =
+                UNKNOWN_SIZE == childSizeHint
+                ? ImmutableYangModeledAnyXmlNodeBuilder.create((YangModeledAnyXmlSchemaNode) nextSchema)
+                        : ImmutableYangModeledAnyXmlNodeBuilder.create(
                 (YangModeledAnyXmlSchemaNode) nextSchema, childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
@@ -238,17 +242,19 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
 
-        final CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableUnkeyedListNodeBuilder.create() : ImmutableUnkeyedListNodeBuilder.create(childSizeHint);
+        final CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> builder =
+                UNKNOWN_SIZE == childSizeHint ? ImmutableUnkeyedListNodeBuilder.create()
+                        : ImmutableUnkeyedListNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
     @Override
     public void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) {
-        Preconditions.checkArgument((getCurrent() instanceof NormalizedNodeResultBuilder)
+        Preconditions.checkArgument(getCurrent() instanceof NormalizedNodeResultBuilder
                 || getCurrent() instanceof ImmutableUnkeyedListNodeBuilder);
-        final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableUnkeyedListEntryNodeBuilder.create() : ImmutableUnkeyedListEntryNodeBuilder.create(childSizeHint);
+        final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> builder =
+                UNKNOWN_SIZE == childSizeHint ? ImmutableUnkeyedListEntryNodeBuilder.create()
+                        : ImmutableUnkeyedListEntryNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
@@ -256,19 +262,21 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void startMapNode(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
 
-        final CollectionNodeBuilder<MapEntryNode, MapNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableMapNodeBuilder.create() : ImmutableMapNodeBuilder.create(childSizeHint);
+        final CollectionNodeBuilder<MapEntryNode, MapNode> builder = UNKNOWN_SIZE == childSizeHint
+                ImmutableMapNodeBuilder.create() : ImmutableMapNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
     @Override
     public void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint) {
         if (!(getCurrent() instanceof NormalizedNodeResultBuilder)) {
-            Preconditions.checkArgument(getCurrent() instanceof ImmutableMapNodeBuilder || getCurrent() instanceof ImmutableOrderedMapNodeBuilder);
+            Preconditions.checkArgument(getCurrent() instanceof ImmutableMapNodeBuilder
+                || getCurrent() instanceof ImmutableOrderedMapNodeBuilder);
         }
 
-        final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableMapEntryNodeBuilder.create() : ImmutableMapEntryNodeBuilder.create(childSizeHint);
+        final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder =
+                UNKNOWN_SIZE == childSizeHint ? ImmutableMapEntryNodeBuilder.create()
+                        : ImmutableMapEntryNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(identifier));
     }
 
@@ -276,8 +284,8 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
 
-        final CollectionNodeBuilder<MapEntryNode, OrderedMapNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableOrderedMapNodeBuilder.create() : ImmutableOrderedMapNodeBuilder.create(childSizeHint);
+        final CollectionNodeBuilder<MapEntryNode, OrderedMapNode> builder = UNKNOWN_SIZE == childSizeHint
+                ImmutableOrderedMapNodeBuilder.create() : ImmutableOrderedMapNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
@@ -285,8 +293,8 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
     public void startChoiceNode(final NodeIdentifier name, final int childSizeHint) {
         checkDataNodeContainer();
 
-        final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> builder = UNKNOWN_SIZE == childSizeHint ?
-                ImmutableChoiceNodeBuilder.create() : ImmutableChoiceNodeBuilder.create(childSizeHint);
+        final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> builder = UNKNOWN_SIZE == childSizeHint
+                ImmutableChoiceNodeBuilder.create() : ImmutableChoiceNodeBuilder.create(childSizeHint);
         enter(builder.withNodeIdentifier(name));
     }
 
@@ -299,8 +307,7 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
 
     private void checkDataNodeContainer() {
         @SuppressWarnings("rawtypes")
-        final
-        NormalizedNodeContainerBuilder current = getCurrent();
+        final NormalizedNodeContainerBuilder current = getCurrent();
         if (!(current instanceof NormalizedNodeResultBuilder)) {
             Preconditions.checkArgument(current instanceof DataContainerNodeBuilder<?, ?>, "Invalid nesting of data.");
         }
@@ -321,17 +328,17 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
         }
 
         @Override
-        public NormalizedNode build() {
-            throw new IllegalStateException("Can not close NormalizedNodeResult");
+        public NormalizedNodeContainerBuilder withValue(final Collection value) {
+            throw new UnsupportedOperationException();
         }
 
         @Override
-        public NormalizedNodeContainerBuilder withNodeIdentifier(final PathArgument nodeIdentifier) {
-            throw new UnsupportedOperationException();
+        public NormalizedNode build() {
+            throw new IllegalStateException("Can not close NormalizedNodeResult");
         }
 
         @Override
-        public NormalizedNodeContainerBuilder withValue(final Collection value) {
+        public NormalizedNodeContainerBuilder withNodeIdentifier(final PathArgument nodeIdentifier) {
             throw new UnsupportedOperationException();
         }
 
@@ -345,7 +352,6 @@ public class ImmutableNormalizedNodeStreamWriter implements NormalizedNodeStream
         public NormalizedNodeContainerBuilder removeChild(final PathArgument key) {
             throw new UnsupportedOperationException();
         }
-
     }
 
     @Override
index f2530f73bbadada5978890727ab6b6885e05600e..b1c2b9a6e041298c354ce040b8533e5265da8c58 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
@@ -20,6 +21,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -55,8 +57,8 @@ import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
 
 /**
-* Base strategy for converting an instance identifier into a normalized node structure for container-like types.
-*/
+ * Base strategy for converting an instance identifier into a normalized node structure for container-like types.
+ */
 abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends InstanceIdToNodes<T> {
 
     protected InstanceIdToCompositeNodes(final T identifier) {
@@ -71,7 +73,8 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
         return new AugmentationIdentifier(potentialChildren.build());
     }
 
-    private static DataNodeContainer augmentationProxy(final AugmentationSchema augmentation, final DataNodeContainer schema) {
+    private static DataNodeContainer augmentationProxy(final AugmentationSchema augmentation,
+            final DataNodeContainer schema) {
         final Set<DataSchemaNode> children = new HashSet<>();
         for (final DataSchemaNode augNode : augmentation.getChildNodes()) {
             children.add(schema.getDataChildByName(augNode.getQName()));
@@ -81,7 +84,8 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
 
     @Override
     @SuppressWarnings("unchecked")
-    public final NormalizedNode<?, ?> create(final YangInstanceIdentifier instanceId, final Optional<NormalizedNode<?, ?>> lastChild, final Optional<Map.Entry<QName,ModifyAction>> operation) {
+    public final NormalizedNode<?, ?> create(final YangInstanceIdentifier instanceId,
+            final Optional<NormalizedNode<?, ?>> lastChild, final Optional<Entry<QName,ModifyAction>> operation) {
         checkNotNull(instanceId);
         final Iterator<PathArgument> iterator = instanceId.getPathArguments().iterator();
         final PathArgument legacyData = iterator.next();
@@ -97,7 +101,8 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
             final PathArgument childPath = iterator.next();
             final InstanceIdToNodes<?> childOp = getChildOperation(childPath);
 
-            final YangInstanceIdentifier childId = YangInstanceIdentifier.create(Iterables.skip(instanceId.getPathArguments(), 1));
+            final YangInstanceIdentifier childId = YangInstanceIdentifier.create(
+                Iterables.skip(instanceId.getPathArguments(), 1));
             builder.addChild(childOp.create(childId, lastChild, operation));
         } else {
             if (lastChild.isPresent()) {
@@ -105,13 +110,14 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
             }
             if (operation.isPresent()) {
                 Preconditions.checkArgument(builder instanceof AttributesBuilder<?>);
-                addModifyOpIfPresent(operation, ((AttributesBuilder<?>) builder));
+                addModifyOpIfPresent(operation, (AttributesBuilder<?>) builder);
             }
         }
 
         return builder.build();
     }
 
+    @SuppressWarnings("checkstyle:illegalCatch")
     private InstanceIdToNodes<?> getChildOperation(final PathArgument childPath) {
         final InstanceIdToNodes<?> childOp;
         try {
@@ -123,10 +129,10 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
         return childOp;
     }
 
-    protected abstract NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(final PathArgument compositeNode);
+    protected abstract NormalizedNodeContainerBuilder<?, ?, ?, ?> createBuilder(PathArgument compositeNode);
 
-    static abstract class DataContainerNormalizationOperation<T extends PathArgument> extends
-            InstanceIdToCompositeNodes<T> {
+    abstract static class DataContainerNormalizationOperation<T extends PathArgument>
+            extends InstanceIdToCompositeNodes<T> {
 
         private final DataNodeContainer schema;
         private final Map<PathArgument, InstanceIdToNodes<?>> byArg;
@@ -169,10 +175,12 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
         }
 
         @Override
-        protected DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> createBuilder(final PathArgument currentArg) {
+        protected DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> createBuilder(
+                final PathArgument currentArg) {
+            final NodeIdentifierWithPredicates arg = (NodeIdentifierWithPredicates) currentArg;
             final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> builder = Builders
-                    .mapEntryBuilder().withNodeIdentifier((NodeIdentifierWithPredicates) currentArg);
-            for (final Map.Entry<QName, Object> keyValue : ((NodeIdentifierWithPredicates) currentArg).getKeyValues().entrySet()) {
+                    .mapEntryBuilder().withNodeIdentifier(arg);
+            for (final Entry<QName, Object> keyValue : arg.getKeyValues().entrySet()) {
                 builder.addChild(Builders.leafBuilder()
                         .withNodeIdentifier(NodeIdentifier.create(keyValue.getKey())).withValue(keyValue.getValue())
                         .build());
@@ -187,13 +195,13 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class UnkeyedListItemNormalization extends DataContainerNormalizationOperation<NodeIdentifier> {
-
-        protected UnkeyedListItemNormalization(final ListSchemaNode schema) {
+        UnkeyedListItemNormalization(final ListSchemaNode schema) {
             super(NodeIdentifier.create(schema.getQName()), schema);
         }
 
         @Override
-        protected DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> createBuilder(final PathArgument compositeNode) {
+        protected DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> createBuilder(
+                final PathArgument compositeNode) {
             return Builders.unkeyedListEntryBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -204,12 +212,13 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class ContainerTransformation extends DataContainerNormalizationOperation<NodeIdentifier> {
-        protected ContainerTransformation(final ContainerSchemaNode schema) {
+        ContainerTransformation(final ContainerSchemaNode schema) {
             super(NodeIdentifier.create(schema.getQName()), schema);
         }
 
         @Override
-        protected DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createBuilder(final PathArgument compositeNode) {
+        protected DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createBuilder(
+                final PathArgument compositeNode) {
             return Builders.containerBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -220,9 +229,7 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class OrderedLeafListMixinNormalization extends UnorderedLeafListMixinNormalization {
-
-
-        public OrderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
+        OrderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
             super(potential);
         }
 
@@ -233,10 +240,9 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static class UnorderedLeafListMixinNormalization extends InstanceIdToCompositeNodes<NodeIdentifier> {
-
         private final InstanceIdToNodes<?> innerOp;
 
-        public UnorderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
+        UnorderedLeafListMixinNormalization(final LeafListSchemaNode potential) {
             super(NodeIdentifier.create(potential.getQName()));
             innerOp = new InstanceIdToSimpleNodes.LeafListEntryNormalization(potential);
         }
@@ -261,13 +267,13 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class AugmentationNormalization extends DataContainerNormalizationOperation<AugmentationIdentifier> {
-
-        public AugmentationNormalization(final AugmentationSchema augmentation, final DataNodeContainer schema) {
+        AugmentationNormalization(final AugmentationSchema augmentation, final DataNodeContainer schema) {
             super(augmentationIdentifierFrom(augmentation), augmentationProxy(augmentation, schema));
         }
 
         @Override
-        protected DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> createBuilder(final PathArgument compositeNode) {
+        protected DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> createBuilder(
+                final PathArgument compositeNode) {
             return Builders.augmentationBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -278,17 +284,17 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static class UnorderedMapMixinNormalization extends InstanceIdToCompositeNodes<NodeIdentifier> {
-
         private final ListItemNormalization innerNode;
 
-        public UnorderedMapMixinNormalization(final ListSchemaNode list) {
+        UnorderedMapMixinNormalization(final ListSchemaNode list) {
             super(NodeIdentifier.create(list.getQName()));
             this.innerNode = new ListItemNormalization(new NodeIdentifierWithPredicates(list.getQName(),
                     Collections.emptyMap()), list);
         }
 
         @Override
-        protected CollectionNodeBuilder<MapEntryNode, ? extends MapNode> createBuilder(final PathArgument compositeNode) {
+        protected CollectionNodeBuilder<MapEntryNode, ? extends MapNode> createBuilder(
+                final PathArgument compositeNode) {
             return Builders.mapBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -307,8 +313,7 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class OrderedMapMixinNormalization extends UnorderedMapMixinNormalization {
-
-        public OrderedMapMixinNormalization(final ListSchemaNode list) {
+        OrderedMapMixinNormalization(final ListSchemaNode list) {
             super(list);
         }
 
@@ -320,10 +325,9 @@ abstract class InstanceIdToCompositeNodes<T extends PathArgument> extends Instan
     }
 
     static final class ChoiceNodeNormalization extends InstanceIdToCompositeNodes<NodeIdentifier> {
-
         private final ImmutableMap<PathArgument, InstanceIdToNodes<?>> byArg;
 
-        protected ChoiceNodeNormalization(final ChoiceSchemaNode schema) {
+        ChoiceNodeNormalization(final ChoiceSchemaNode schema) {
             super(NodeIdentifier.create(schema.getQName()));
             final ImmutableMap.Builder<PathArgument, InstanceIdToNodes<?>> byArgBuilder = ImmutableMap.builder();
 
index 05ae74df6e0663cb8a199f266cd924273db29e10..54c64e93815a3408e49df5e0d251248f8f9c2065 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Iterables;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map.Entry;
@@ -57,29 +57,31 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
     }
 
     /**
-     * Build a strategy for the next path argument
+     * Build a strategy for the next path argument.
      *
      * @param child child identifier
      * @return transformation strategy for a specific child
      */
-    abstract InstanceIdToNodes<?> getChild(final PathArgument child);
+    abstract InstanceIdToNodes<?> getChild(PathArgument child);
 
     /**
-     *
-     * Convert instance identifier into a NormalizedNode structure
+     * Convert instance identifier into a NormalizedNode structure.
      *
      * @param instanceId Instance identifier to transform into NormalizedNodes
      * @param deepestChild Optional normalized node to be inserted as the last child
      * @param operation Optional modify operation to be set on the last child
      * @return NormalizedNode structure corresponding to submitted instance ID
      */
-    abstract NormalizedNode<?, ?> create(YangInstanceIdentifier instanceId, Optional<NormalizedNode<?, ?>> deepestChild, Optional<Entry<QName,ModifyAction>> operation);
+    abstract NormalizedNode<?, ?> create(YangInstanceIdentifier instanceId, Optional<NormalizedNode<?, ?>> deepestChild,
+            Optional<Entry<QName,ModifyAction>> operation);
 
     abstract boolean isMixin();
 
-    public void addModifyOpIfPresent(final Optional<Entry<QName,ModifyAction>> operation, final AttributesBuilder<?> builder) {
+    public void addModifyOpIfPresent(final Optional<Entry<QName,ModifyAction>> operation,
+            final AttributesBuilder<?> builder) {
         if (operation.isPresent()) {
-            builder.withAttributes(Collections.singletonMap(operation.get().getKey(), modifyOperationToXmlString(operation.get().getValue())));
+            builder.withAttributes(Collections.singletonMap(operation.get().getKey(),
+                modifyOperationToXmlString(operation.get().getValue())));
         }
     }
 
@@ -87,17 +89,17 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
         return operation.name().toLowerCase();
     }
 
-    private final static class UnkeyedListMixinNormalization extends InstanceIdToCompositeNodes<NodeIdentifier> {
-
+    private static final class UnkeyedListMixinNormalization extends InstanceIdToCompositeNodes<NodeIdentifier> {
         private final UnkeyedListItemNormalization innerNode;
 
-        public UnkeyedListMixinNormalization(final ListSchemaNode list) {
+        UnkeyedListMixinNormalization(final ListSchemaNode list) {
             super(NodeIdentifier.create(list.getQName()));
             this.innerNode = new UnkeyedListItemNormalization(list);
         }
 
         @Override
-        protected CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> createBuilder(final PathArgument compositeNode) {
+        protected CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> createBuilder(
+                final PathArgument compositeNode) {
             return Builders.unkeyedListBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -116,8 +118,7 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
     }
 
     private static class AnyXmlNormalization extends InstanceIdToNodes<NodeIdentifier> {
-
-        protected AnyXmlNormalization(final AnyXmlSchemaNode schema) {
+        AnyXmlNormalization(final AnyXmlSchemaNode schema) {
             super(NodeIdentifier.create(schema.getQName()));
         }
 
@@ -135,7 +136,8 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
                 Preconditions.checkState(child instanceof AnyXmlNode);
 
                 final NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> anyXmlBuilder =
-                        Builders.anyXmlBuilder().withNodeIdentifier(getIdentifier()).withValue(((AnyXmlNode) child).getValue());
+                        Builders.anyXmlBuilder().withNodeIdentifier(getIdentifier()).withValue(
+                            ((AnyXmlNode) child).getValue());
                 addModifyOpIfPresent(operation, anyXmlBuilder);
                 return anyXmlBuilder.build();
             }
@@ -155,8 +157,7 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
     private static Optional<DataSchemaNode> findChildSchemaNode(final DataNodeContainer parent, final QName child) {
         DataSchemaNode potential = parent.getDataChildByName(child);
         if (potential == null) {
-            final Iterable<ChoiceSchemaNode> choices = FluentIterable.from(parent.getChildNodes()).filter(ChoiceSchemaNode.class);
-            potential = findChoice(choices, child);
+            potential = findChoice(Iterables.filter(parent.getChildNodes(), ChoiceSchemaNode.class), child);
         }
         return Optional.fromNullable(potential);
     }
@@ -164,7 +165,8 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
     static InstanceIdToNodes<?> fromSchemaAndQNameChecked(final DataNodeContainer schema, final QName child) {
         final Optional<DataSchemaNode> potential = findChildSchemaNode(schema, child);
         Preconditions.checkArgument(potential.isPresent(),
-                "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema, schema.getChildNodes());
+                "Supplied QName %s is not valid according to schema %s, potential children nodes: %s", child, schema,
+                schema.getChildNodes());
 
         final DataSchemaNode result = potential.get();
         // We try to look up if this node was added by augmentation
@@ -197,7 +199,7 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
      * call for {@link #fromDataSchemaNode(org.opendaylight.yangtools.yang.model.api.DataSchemaNode)}.
      */
     private static InstanceIdToNodes<?> fromAugmentation(final DataNodeContainer parent,
-                                                          final AugmentationTarget parentAug, final DataSchemaNode child) {
+            final AugmentationTarget parentAug, final DataSchemaNode child) {
         AugmentationSchema augmentation = null;
         for (final AugmentationSchema aug : parentAug.getAvailableAugmentations()) {
             final DataSchemaNode potential = aug.getDataChildByName(child.getQName());
@@ -247,6 +249,4 @@ abstract class InstanceIdToNodes<T extends PathArgument> implements Identifiable
         }
         return new InstanceIdToCompositeNodes.UnorderedLeafListMixinNormalization(potential);
     }
-
-
 }
index 17b8cff7a13f5cc28a5ad6fdcf90e870ff0c1b61..407fcba793bc560a9b9454213577decb2e3f4953 100644 (file)
@@ -8,9 +8,10 @@
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
-import java.util.Map;
+import java.util.Map.Entry;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.ModifyAction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -34,10 +35,12 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
     }
 
     @Override
-    public NormalizedNode<?, ?> create(final YangInstanceIdentifier instanceId, final Optional<NormalizedNode<?, ?>> deepestChild, final Optional<Map.Entry<QName,ModifyAction>> operation) {
+    public NormalizedNode<?, ?> create(final YangInstanceIdentifier instanceId,
+            final Optional<NormalizedNode<?, ?>> deepestChild, final Optional<Entry<QName, ModifyAction>> operation) {
         checkNotNull(instanceId);
         final PathArgument pathArgument = instanceId.getPathArguments().get(0);
-        final NormalizedNodeAttrBuilder<? extends PathArgument, Object, ? extends NormalizedNode<? extends PathArgument, Object>> builder = getBuilder(pathArgument);
+        final NormalizedNodeAttrBuilder<? extends PathArgument, Object,
+                ? extends NormalizedNode<? extends PathArgument, Object>> builder = getBuilder(pathArgument);
 
         if (deepestChild.isPresent()) {
             builder.withValue(deepestChild.get().getValue());
@@ -47,7 +50,8 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
         return builder.build();
     }
 
-    protected abstract NormalizedNodeAttrBuilder<? extends PathArgument, Object, ? extends NormalizedNode<? extends PathArgument, Object>> getBuilder(PathArgument node);
+    protected abstract NormalizedNodeAttrBuilder<? extends PathArgument, Object,
+            ? extends NormalizedNode<? extends PathArgument, Object>> getBuilder(PathArgument node);
 
     @Override
     public InstanceIdToNodes<?> getChild(final PathArgument child) {
@@ -55,13 +59,13 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
     }
 
     static final class LeafNormalization extends InstanceIdToSimpleNodes<NodeIdentifier> {
-
-        protected LeafNormalization(final LeafSchemaNode potential) {
+        LeafNormalization(final LeafSchemaNode potential) {
             super(new NodeIdentifier(potential.getQName()));
         }
 
         @Override
-        protected NormalizedNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, Object, LeafNode<Object>> getBuilder(final PathArgument node) {
+        protected NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> getBuilder(
+                final PathArgument node) {
             return Builders.leafBuilder().withNodeIdentifier(getIdentifier());
         }
 
@@ -72,15 +76,16 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
     }
 
     static final class LeafListEntryNormalization extends InstanceIdToSimpleNodes<NodeWithValue> {
-
-        public LeafListEntryNormalization(final LeafListSchemaNode potential) {
-            super(new YangInstanceIdentifier.NodeWithValue<>(potential.getQName(), null));
+        LeafListEntryNormalization(final LeafListSchemaNode potential) {
+            super(new NodeWithValue<>(potential.getQName(), null));
         }
 
         @Override
-        protected NormalizedNodeAttrBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> getBuilder(final YangInstanceIdentifier.PathArgument node) {
-            Preconditions.checkArgument(node instanceof YangInstanceIdentifier.NodeWithValue);
-            return Builders.leafSetEntryBuilder().withNodeIdentifier((YangInstanceIdentifier.NodeWithValue<?>) node).withValue(((YangInstanceIdentifier.NodeWithValue<?>) node).getValue());
+        protected NormalizedNodeAttrBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> getBuilder(
+                final PathArgument node) {
+            Preconditions.checkArgument(node instanceof NodeWithValue);
+            return Builders.leafSetEntryBuilder().withNodeIdentifier((NodeWithValue<?>) node)
+                    .withValue(((NodeWithValue<?>) node).getValue());
         }
 
         @Override
index 47723fd788f00ed91ce4f499fcd245e258e27be8..85d41a78a16c5cada404315015a36daba7ad1b0e 100644 (file)
@@ -10,20 +10,19 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 /**
- * Client allocated result holder for {@link ImmutableNormalizedNodeStreamWriter}.
- * which produces instance of NormalizedNode.
+ * Client allocated result holder for {@link ImmutableNormalizedNodeStreamWriter} which produces instance
+ * of NormalizedNode.
  *
- * Client may supply result holder to {@link ImmutableNormalizedNodeStreamWriter}
- * which will be once updated, when result is available.
- *
- * This is intended for using {@link ImmutableNormalizedNodeStreamWriter}
- * without supplying builder, so instantiated writer will select
- * correct builder based on first event and sets resulting
- *  {@link NormalizedNode} when end event is invoked for node.
+ * <p>
+ * Client may supply result holder to {@link ImmutableNormalizedNodeStreamWriter} which will be once updated when
+ * the result is available.
  *
+ * <p>
+ * This is intended for using {@link ImmutableNormalizedNodeStreamWriter} without supplying builder, so instantiated
+ * writer will select correct builder based on first event and sets resulting {@link NormalizedNode} when end event is
+ * invoked for node.
  */
 public class NormalizedNodeResult {
-
     private boolean finished = false;
     private NormalizedNode<?,?> result;
 
@@ -42,5 +41,4 @@ public class NormalizedNodeResult {
     public boolean isFinished() {
         return finished;
     }
-
 }
index f066f29f6c8ae5a8f036159a23b80fb11403d005..483a86c276420616d2d37bbfd9b2ec2c3e4018a5 100644 (file)
@@ -11,13 +11,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 public class ResultAlreadySetException extends IllegalStateException {
     private static final long serialVersionUID = 1L;
+
     private final NormalizedNode<?, ?> resultData;
 
     public ResultAlreadySetException(final String message, final NormalizedNode<?, ?> resultData) {
         this(message, resultData, null);
     }
 
-    public ResultAlreadySetException(final String message, final NormalizedNode<?, ?> resultData, final Throwable cause) {
+    public ResultAlreadySetException(final String message, final NormalizedNode<?, ?> resultData,
+            final Throwable cause) {
         super(message, cause);
         this.resultData = resultData;
     }
index 4cd619b8116767cefbd006c99efb4561ca1ca1d5..186d88c55dcbb9b1f5cff5840b4e364e057b152b 100644 (file)
@@ -31,8 +31,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * This is an iterator over a {@link NormalizedNode}. Unlike {@link NormalizedNodeWriter},
- * this iterates over elements in order as they are defined in .yang file.
+ * This is an iterator over a {@link NormalizedNode}. Unlike {@link NormalizedNodeWriter}, this iterates over elements
+ * in the order as they are defined in YANG file.
  */
 public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
     private static final Logger LOG = LoggerFactory.getLogger(SchemaOrderedNormalizedNodeWriter.class);
@@ -74,7 +74,6 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
             currentSchemaNode = root;
         }
         return write(node, currentSchemaNode);
-
     }
 
     /**
@@ -92,10 +91,10 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
         }
 
         throw new IllegalStateException("It wasn't possible to serialize nodes " + nodes);
-
     }
 
-    private SchemaOrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node, final SchemaNode dataSchemaNode) throws IOException {
+    private SchemaOrderedNormalizedNodeWriter write(final NormalizedNode<?, ?> node, final SchemaNode dataSchemaNode)
+            throws IOException {
 
         //Set current schemaNode
         try (SchemaNodeSetter sns = new SchemaNodeSetter(dataSchemaNode)) {
@@ -126,7 +125,8 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
         return writeChildren(children, currentSchemaNode, true);
     }
 
-    private boolean writeChildren(final Iterable<? extends NormalizedNode<?, ?>> children, final SchemaNode parentSchemaNode, final boolean endParent) throws IOException {
+    private boolean writeChildren(final Iterable<? extends NormalizedNode<?, ?>> children,
+            final SchemaNode parentSchemaNode, final boolean endParent) throws IOException {
         //Augmentations cannot be gotten with node.getChild so create our own structure with augmentations resolved
         final ArrayListMultimap<QName, NormalizedNode<?, ?>> qNameToNodes = ArrayListMultimap.create();
         for (final NormalizedNode<?, ?> child : children) {
@@ -184,26 +184,24 @@ public class SchemaOrderedNormalizedNodeWriter extends NormalizedNodeWriter {
         return resolvedAugs;
     }
 
-
-    private class SchemaNodeSetter implements AutoCloseable {
+    private final class SchemaNodeSetter implements AutoCloseable {
 
         private final SchemaNode previousSchemaNode;
 
         /**
-         * Sets current schema node new value and store old value for later restore
+         * Sets current schema node new value and store old value for later restore.
          */
-        public SchemaNodeSetter(final SchemaNode schemaNode) {
+        SchemaNodeSetter(final SchemaNode schemaNode) {
             previousSchemaNode = SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode;
             SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode = schemaNode;
         }
 
         /**
-         * Restore previous schema node
+         * Restore previous schema node.
          */
         @Override
         public void close() {
             SchemaOrderedNormalizedNodeWriter.this.currentSchemaNode = previousSchemaNode;
         }
     }
-
 }
\ No newline at end of file
index 1999c657d5c8f80c83bcd9e7dbbfa2ecdc9ae5fb..b401fccb528b6c0684de3d1c81b7bbedc5c46ff2 100644 (file)
@@ -47,17 +47,20 @@ public final class SchemaUtils {
     }
 
     /**
-     * @param qname - schema node to find
-     * @param dataSchemaNode - iterable of schemaNodes to look through
-     * @return - schema node with newest revision or absent if no schema node with matching qname is found
+     * Find the first schema with specified QName.
+     *
+     * @param qname schema node to find
+     * @param dataSchemaNode Iterable of schemaNodes to look through
+     * @return schema node with newest revision or absent if no schema node with matching qname is found
      */
-    public static Optional<DataSchemaNode> findFirstSchema(final QName qname, final Iterable<DataSchemaNode> dataSchemaNode) {
-        DataSchemaNode sNode = null;
+    public static Optional<DataSchemaNode> findFirstSchema(final QName qname,
+            final Iterable<DataSchemaNode> dataSchemaNode) {
+        DataSchemaNode schema = null;
         if (dataSchemaNode != null && qname != null) {
             for (final DataSchemaNode dsn : dataSchemaNode) {
                 if (qname.isEqualWithoutRevision(dsn.getQName())) {
-                    if (sNode == null || sNode.getQName().getRevision().compareTo(dsn.getQName().getRevision()) < 0) {
-                        sNode = dsn;
+                    if (schema == null || schema.getQName().getRevision().compareTo(dsn.getQName().getRevision()) < 0) {
+                        schema = dsn;
                     }
                 } else if (dsn instanceof ChoiceSchemaNode) {
                     for (final ChoiceCaseNode choiceCase : ((ChoiceSchemaNode) dsn).getCases()) {
@@ -74,12 +77,11 @@ public final class SchemaUtils {
                 }
             }
         }
-        return Optional.fromNullable(sNode);
+        return Optional.fromNullable(schema);
     }
 
     /**
-     *
-     * Find child schema node identified by its QName within a provided schema node
+     * Find child schema node identified by its QName within a provided schema node.
      *
      * @param schema schema for parent node - search root
      * @param qname qname(with or without a revision) of a child node to be found in the parent schema
@@ -87,13 +89,15 @@ public final class SchemaUtils {
      * @throws java.lang.IllegalStateException if the child was not found in parent schema node
      */
     public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
-        // Try to find child schema node directly, but use a fallback that compares QNames without revisions and auto-expands choices
+        // Try to find child schema node directly, but use a fallback that compares QNames without revisions
+        // and auto-expands choices
         final DataSchemaNode dataChildByName = schema.getDataChildByName(qname);
         return dataChildByName == null ? findSchemaForChild(schema, qname, schema.getChildNodes()) : dataChildByName;
     }
 
     @Nullable
-    public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final boolean strictMode) {
+    public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname,
+            final boolean strictMode) {
         if (strictMode) {
             return findSchemaForChild(schema, qname);
         }
@@ -105,41 +109,56 @@ public final class SchemaUtils {
         return childSchemaOptional.get();
     }
 
-    public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final Iterable<DataSchemaNode> childNodes) {
+    public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname,
+            final Iterable<DataSchemaNode> childNodes) {
         final Optional<DataSchemaNode> childSchema = findFirstSchema(qname, childNodes);
         Preconditions.checkState(childSchema.isPresent(),
                 "Unknown child(ren) node(s) detected, identified by: %s, in: %s", qname, schema);
         return childSchema.get();
     }
 
-    public static AugmentationSchema findSchemaForAugment(final AugmentationTarget schema, final Set<QName> qNames) {
-        final Optional<AugmentationSchema> schemaForAugment = findAugment(schema, qNames);
-        Preconditions.checkState(schemaForAugment.isPresent(), "Unknown augmentation node detected, identified by: %s, in: %s",
-                qNames, schema);
+    public static DataSchemaNode findSchemaForChild(final ChoiceSchemaNode schema, final QName childPartialQName) {
+        for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
+            final Optional<DataSchemaNode> childSchema = findFirstSchema(childPartialQName,
+                choiceCaseNode.getChildNodes());
+            if (childSchema.isPresent()) {
+                return childSchema.get();
+            }
+        }
+
+
+        throw new IllegalStateException(String.format("Unknown child(ren) node(s) detected, identified by: %s, in: %s",
+                childPartialQName, schema));
+    }
+
+    public static AugmentationSchema findSchemaForAugment(final AugmentationTarget schema, final Set<QName> qnames) {
+        final Optional<AugmentationSchema> schemaForAugment = findAugment(schema, qnames);
+        Preconditions.checkState(schemaForAugment.isPresent(),
+            "Unknown augmentation node detected, identified by: %s, in: %s", qnames, schema);
         return schemaForAugment.get();
     }
 
-    public static AugmentationSchema findSchemaForAugment(final ChoiceSchemaNode schema, final Set<QName> qNames) {
+    public static AugmentationSchema findSchemaForAugment(final ChoiceSchemaNode schema, final Set<QName> qnames) {
         Optional<AugmentationSchema> schemaForAugment = Optional.absent();
 
         for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
-            schemaForAugment = findAugment(choiceCaseNode, qNames);
+            schemaForAugment = findAugment(choiceCaseNode, qnames);
             if (schemaForAugment.isPresent()) {
                 break;
             }
         }
 
-        Preconditions.checkState(schemaForAugment.isPresent(), "Unknown augmentation node detected, identified by: %s, in: %s",
-                qNames, schema);
+        Preconditions.checkState(schemaForAugment.isPresent(),
+            "Unknown augmentation node detected, identified by: %s, in: %s", qnames, schema);
         return schemaForAugment.get();
     }
 
-    private static Optional<AugmentationSchema> findAugment(final AugmentationTarget schema, final Set<QName> qNames) {
+    private static Optional<AugmentationSchema> findAugment(final AugmentationTarget schema, final Set<QName> qnames) {
         for (final AugmentationSchema augment : schema.getAvailableAugmentations()) {
             final HashSet<QName> qNamesFromAugment = Sets.newHashSet(Collections2.transform(augment.getChildNodes(),
                 DataSchemaNode::getQName));
 
-            if (qNamesFromAugment.equals(qNames)) {
+            if (qNamesFromAugment.equals(qnames)) {
                 return Optional.of(augment);
             }
         }
@@ -147,19 +166,6 @@ public final class SchemaUtils {
         return Optional.absent();
     }
 
-    public static DataSchemaNode findSchemaForChild(final ChoiceSchemaNode schema, final QName childPartialQName) {
-        for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
-            final Optional<DataSchemaNode> childSchema = findFirstSchema(childPartialQName, choiceCaseNode.getChildNodes());
-            if (childSchema.isPresent()) {
-                return childSchema.get();
-            }
-        }
-
-
-        throw new IllegalStateException(String.format("Unknown child(ren) node(s) detected, identified by: %s, in: %s",
-                childPartialQName, schema));
-    }
-
     /**
      * Recursively find all child nodes that come from choices.
      *
@@ -170,7 +176,8 @@ public final class SchemaUtils {
         return mapChildElementsFromChoices(schema, schema.getChildNodes());
     }
 
-    private static Map<QName, ChoiceSchemaNode> mapChildElementsFromChoices(final DataNodeContainer schema, final Iterable<DataSchemaNode> childNodes) {
+    private static Map<QName, ChoiceSchemaNode> mapChildElementsFromChoices(final DataNodeContainer schema,
+            final Iterable<DataSchemaNode> childNodes) {
         final Map<QName, ChoiceSchemaNode> mappedChoices = Maps.newLinkedHashMap();
 
         for (final DataSchemaNode childSchema : childNodes) {
@@ -181,9 +188,8 @@ public final class SchemaUtils {
                 }
 
                 for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) childSchema).getCases()) {
-
-                    for (final QName qName : getChildNodesRecursive(choiceCaseNode)) {
-                        mappedChoices.put(qName, (ChoiceSchemaNode) childSchema);
+                    for (final QName qname : getChildNodesRecursive(choiceCaseNode)) {
+                        mappedChoices.put(qname, (ChoiceSchemaNode) childSchema);
                     }
                 }
             }
@@ -230,7 +236,7 @@ public final class SchemaUtils {
 
             for (final DataSchemaNode child : ((DataNodeContainer) schema).getChildNodes()) {
                 // If is not augmented child, continue
-                if (!(augments.containsKey(child.getQName()))) {
+                if (!augments.containsKey(child.getQName())) {
                     continue;
                 }
 
@@ -238,13 +244,13 @@ public final class SchemaUtils {
 
                 // recursively add all child nodes in case of augment, case and choice
                 if (child instanceof AugmentationSchema || child instanceof ChoiceCaseNode) {
-                    for (final QName qName : getChildNodesRecursive((DataNodeContainer) child)) {
-                        childNodesToAugmentation.put(qName, mostTopAugmentation);
+                    for (final QName qname : getChildNodesRecursive((DataNodeContainer) child)) {
+                        childNodesToAugmentation.put(qname, mostTopAugmentation);
                     }
                 } else if (child instanceof ChoiceSchemaNode) {
                     for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) child).getCases()) {
-                        for (final QName qName : getChildNodesRecursive(choiceCaseNode)) {
-                            childNodesToAugmentation.put(qName, mostTopAugmentation);
+                        for (final QName qname : getChildNodesRecursive(choiceCaseNode)) {
+                            childNodesToAugmentation.put(qname, mostTopAugmentation);
                         }
                     }
                 } else {
@@ -256,12 +262,12 @@ public final class SchemaUtils {
         // Choice Node has to map child nodes from all its cases
         if (schema instanceof ChoiceSchemaNode) {
             for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) schema).getCases()) {
-                if (!(augments.containsKey(choiceCaseNode.getQName()))) {
+                if (!augments.containsKey(choiceCaseNode.getQName())) {
                     continue;
                 }
 
-                for (final QName qName : getChildNodesRecursive(choiceCaseNode)) {
-                    childNodesToAugmentation.put(qName, augments.get(choiceCaseNode.getQName()));
+                for (final QName qname : getChildNodesRecursive(choiceCaseNode)) {
+                    childNodesToAugmentation.put(qname, augments.get(choiceCaseNode.getQName()));
                 }
             }
         }
@@ -270,9 +276,7 @@ public final class SchemaUtils {
     }
 
     /**
-     * Recursively list all child nodes.
-     *
-     * In case of choice, augment and cases, step in.
+     * Recursively list all child nodes. In case of choice, augment and cases, step in.
      *
      * @param nodeContainer node container
      * @return set of QNames
@@ -287,8 +291,7 @@ public final class SchemaUtils {
                 }
             } else if (childSchema instanceof AugmentationSchema || childSchema instanceof ChoiceCaseNode) {
                 allChildNodes.addAll(getChildNodesRecursive((DataNodeContainer) childSchema));
-            }
-            else {
+            } else {
                 allChildNodes.add(childSchema.getQName());
             }
         }
@@ -299,6 +302,7 @@ public final class SchemaUtils {
     /**
      * Retrieves real schemas for augmented child node.
      *
+     * <p>
      * Schema of the same child node from augment, and directly from target is not the same.
      * Schema of child node from augment is incomplete, therefore its useless for XML/NormalizedNode translation.
      *
@@ -306,8 +310,9 @@ public final class SchemaUtils {
      * @param augmentSchema augment schema
      * @return set of nodes
      */
-    public static Set<DataSchemaNode> getRealSchemasForAugment(final AugmentationTarget targetSchema, final AugmentationSchema augmentSchema) {
-        if (!(targetSchema.getAvailableAugmentations().contains(augmentSchema))) {
+    public static Set<DataSchemaNode> getRealSchemasForAugment(final AugmentationTarget targetSchema,
+            final AugmentationSchema augmentSchema) {
+        if (!targetSchema.getAvailableAugmentations().contains(augmentSchema)) {
             return Collections.emptySet();
         }
 
@@ -338,7 +343,8 @@ public final class SchemaUtils {
         return realChildNodes;
     }
 
-    public static Optional<ChoiceCaseNode> detectCase(final ChoiceSchemaNode schema, final DataContainerChild<?, ?> child) {
+    public static Optional<ChoiceCaseNode> detectCase(final ChoiceSchemaNode schema,
+            final DataContainerChild<?, ?> child) {
         for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
             if (child instanceof AugmentationNode
                     && belongsToCaseAugment(choiceCaseNode, (AugmentationIdentifier) child.getIdentifier())) {
@@ -351,7 +357,8 @@ public final class SchemaUtils {
         return Optional.absent();
     }
 
-    public static boolean belongsToCaseAugment(final ChoiceCaseNode caseNode, final AugmentationIdentifier childToProcess) {
+    public static boolean belongsToCaseAugment(final ChoiceCaseNode caseNode,
+            final AugmentationIdentifier childToProcess) {
         for (final AugmentationSchema augmentationSchema : caseNode.getAvailableAugmentations()) {
 
             final Set<QName> currentAugmentChildNodes = Sets.newHashSet();
@@ -359,7 +366,7 @@ public final class SchemaUtils {
                 currentAugmentChildNodes.add(dataSchemaNode.getQName());
             }
 
-            if (childToProcess.getPossibleChildNames().equals(currentAugmentChildNodes)){
+            if (childToProcess.getPossibleChildNames().equals(currentAugmentChildNodes)) {
                 return true;
             }
         }
@@ -413,14 +420,13 @@ public final class SchemaUtils {
     }
 
     /**
-     * Finds schema node for given path in schema context. This method performs
-     * lookup in both the namespace of groupings and the namespace of all leafs,
-     * leaf-lists, lists, containers, choices, rpcs, actions, notifications,
-     * anydatas, and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
+     * Finds schema node for given path in schema context. This method performs lookup in both the namespace
+     * of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions,
+     * notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
      *
-     * This method is deprecated, because name conflicts can occur between the
-     * namespace of groupings and namespace of data nodes and in consequence
-     * lookup could be ambiguous.
+     * <p>
+     * This method is deprecated, because name conflicts can occur between the namespace of groupings and namespace
+     * of data nodes and in consequence lookup could be ambiguous.
      *
      * @param schemaContext
      *            schema context
@@ -428,9 +434,7 @@ public final class SchemaUtils {
      *            path
      * @return schema node on path
      *
-     * @deprecated use
-     *             {@link #findParentSchemaNodesOnPath(SchemaContext, SchemaPath)}
-     *             instead.
+     * @deprecated Use {@link #findParentSchemaNodesOnPath(SchemaContext, SchemaPath)} instead.
      */
     @Deprecated
     public static SchemaNode findParentSchemaOnPath(final SchemaContext schemaContext, final SchemaPath path) {
@@ -442,17 +446,16 @@ public final class SchemaUtils {
     }
 
     /**
-     * Find child data schema node identified by its QName within a provided
-     * schema node. This method performs lookup in the namespace of all leafs,
-     * leaf-lists, lists, containers, choices, rpcs, actions, notifications,
-     * anydatas, and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
+     * Find child data schema node identified by its QName within a provided schema node. This method performs lookup
+     * in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas
+     * and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
      *
      * @param node
      *            schema node
      * @param qname
      *            QName
      * @return data child schema node
-     * @throws java.lang.IllegalArgumentException
+     * @throws IllegalArgumentException
      *             if the schema node does not allow children
      */
     @Nullable
@@ -473,15 +476,15 @@ public final class SchemaUtils {
             child = ((ChoiceSchemaNode) node).getCaseNodeByName(qname);
         } else if (node instanceof RpcDefinition) {
             switch (qname.getLocalName()) {
-            case "input":
-                child = ((RpcDefinition) node).getInput();
-                break;
-            case "output":
-                child = ((RpcDefinition) node).getOutput();
-                break;
-            default:
-                child = null;
-                break;
+                case "input":
+                    child = ((RpcDefinition) node).getInput();
+                    break;
+                case "output":
+                    child = ((RpcDefinition) node).getOutput();
+                    break;
+                default:
+                    child = null;
+                    break;
             }
         } else {
             throw new IllegalArgumentException(String.format("Schema node %s does not allow children.", node));
@@ -491,27 +494,23 @@ public final class SchemaUtils {
     }
 
     /**
-     * Find child schema node identified by its QName within a provided schema
-     * node. This method performs lookup in both the namespace of groupings and
-     * the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
-     * actions, notifications, anydatas, and anyxmls according to
-     * Rfc6050/Rfc7950 section 6.2.1.
+     * Find child schema node identified by its QName within a provided schema node. This method performs lookup
+     * in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
+     * actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.
      *
-     * This method is deprecated, because name conflicts can occur between the
-     * namespace of groupings and namespace of data nodes and in consequence
-     * lookup could be ambiguous.
+     * <p>
+     * This method is deprecated, because name conflicts can occur between the namespace of groupings and namespace
+     * of data nodes and in consequence lookup could be ambiguous.
      *
      * @param node
      *            schema node
      * @param qname
      *            QName
      * @return child schema node
-     * @throws java.lang.IllegalArgumentException
+     * @throws IllegalArgumentException
      *             if the schema node does not allow children
      *
-     * @deprecated use
-     *             {@link #findChildSchemaNodesByQName(SchemaNode, QName)}
-     *             instead.
+     * @deprecated Use {@link #findChildSchemaNodesByQName(SchemaNode, QName)} instead.
      */
     @Deprecated
     public static SchemaNode findChildSchemaByQName(final SchemaNode node, final QName qname) {
@@ -524,14 +523,13 @@ public final class SchemaUtils {
     }
 
     /**
-     * Finds schema node for given path in schema context. This method performs
-     * lookup in both the namespace of groupings and the namespace of all leafs,
-     * leaf-lists, lists, containers, choices, rpcs, actions, notifications,
-     * anydatas, and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
+     * Finds schema node for given path in schema context. This method performs lookup in both the namespace
+     * of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions,
+     * notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.
      *
-     * This method returns collection of SchemaNodes, because name conflicts can
-     * occur between the namespace of groupings and namespace of data nodes.
-     * This method finds and collects all schema nodes that matches supplied
+     * <p>
+     * This method returns collection of SchemaNodes, because name conflicts can occur between the namespace
+     * of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied
      * SchemaPath and returns them all as collection of schema nodes.
      *
      * @param schemaContext
@@ -539,7 +537,6 @@ public final class SchemaUtils {
      * @param path
      *            path
      * @return collection of schema nodes on path
-     *
      */
     public static Collection<SchemaNode> findParentSchemaNodesOnPath(final SchemaContext schemaContext,
             final SchemaPath path) {
@@ -559,25 +556,22 @@ public final class SchemaUtils {
     }
 
     /**
-     * Find child schema node identified by its QName within a provided schema
-     * node. This method performs lookup in both the namespace of groupings and
-     * the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
-     * actions, notifications, anydatas, and anyxmls according to
-     * Rfc6050/Rfc7950 section 6.2.1.
+     * Find child schema node identified by its QName within a provided schema node. This method performs lookup in both
+     * the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs,
+     * actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.
      *
-     * This method returns collection of SchemaNodes, because name conflicts can
-     * occur between the namespace of groupings and namespace of data nodes.
-     * This method finds and collects all schema nodes with supplied QName and
-     * returns them all as collection of schema nodes.
+     * <p>
+     * This method returns collection of SchemaNodes, because name conflicts can occur between the namespace
+     * of groupings and namespace of data nodes. This method finds and collects all schema nodes with supplied QName
+     * and returns them all as collection of schema nodes.
      *
      * @param node
      *            schema node
      * @param qname
      *            QName
      * @return collection of child schema nodes
-     * @throws java.lang.IllegalArgumentException
+     * @throws IllegalArgumentException
      *             if the schema node does not allow children
-     *
      */
     public static Collection<SchemaNode> findChildSchemaNodesByQName(final SchemaNode node, final QName qname) {
         final List<SchemaNode> childNodes = new ArrayList<>();
@@ -610,13 +604,14 @@ public final class SchemaUtils {
     }
 
     private static Optional<SchemaNode> tryFindAction(final ActionNodeContainer actionContanier, final QName qname) {
-        return Optional.fromNullable(Iterables.find(actionContanier.getActions(), new SchemaNodePredicate(qname), null));
+        return Optional.fromNullable(Iterables.find(actionContanier.getActions(), new SchemaNodePredicate(qname),
+            null));
     }
 
     private static final class SchemaNodePredicate implements Predicate<SchemaNode> {
         private final QName qname;
 
-        public SchemaNodePredicate(final QName qname) {
+        SchemaNodePredicate(final QName qname) {
             this.qname = qname;
         }
 
@@ -625,5 +620,4 @@ public final class SchemaUtils {
             return input.getQName().equals(qname);
         }
     }
-
 }
index c793b37b9e22663083c2734288a72407dc0a5cfe..546ce374be49846f48ce7a3b17f1fd660719233d 100644 (file)
@@ -22,5 +22,6 @@ public interface CollectionNodeBuilder<V extends NormalizedNode<?, ?>, R extends
     CollectionNodeBuilder<V, R> withNodeIdentifier(NodeIdentifier nodeIdentifier);
 
     CollectionNodeBuilder<V, R> withChild(V child);
+
     CollectionNodeBuilder<V, R> withoutChild(PathArgument key);
 }
index d7e68a89948175075f4c8cc750dd6203f9fc9be4..1c81af914bc344f3074f3137514f49d635d31943 100644 (file)
@@ -22,5 +22,6 @@ public interface DataContainerNodeBuilder<I extends PathArgument, R extends Data
     DataContainerNodeBuilder<I, R> withNodeIdentifier(I nodeIdentifier);
 
     DataContainerNodeBuilder<I, R> withChild(DataContainerChild<?, ?> child);
+
     DataContainerNodeBuilder<I, R> withoutChild(PathArgument key);
 }
\ No newline at end of file
index 4adcee1add6131990a543b90f90115b728f57594..91e9049d06e4f724cb68621a2e5414d6a049c005 100644 (file)
@@ -11,7 +11,9 @@ import java.util.Collection;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public interface NormalizedNodeContainerBuilder<K extends PathArgument,CK extends PathArgument,CV extends NormalizedNode<? extends CK, ?>,P extends NormalizedNode<K, ?>> extends NormalizedNodeBuilder<K,Collection<CV>,P>{
+public interface NormalizedNodeContainerBuilder<K extends PathArgument, CK extends PathArgument,
+        CV extends NormalizedNode<? extends CK, ?>, P extends NormalizedNode<K, ?>>
+        extends NormalizedNodeBuilder<K, Collection<CV>, P> {
 
     @Override
     NormalizedNodeContainerBuilder<K,CK,CV,P> withNodeIdentifier(K nodeIdentifier);
@@ -20,5 +22,6 @@ public interface NormalizedNodeContainerBuilder<K extends PathArgument,CK extend
     NormalizedNodeContainerBuilder<K,CK,CV,P> withValue(Collection<CV> value);
 
     NormalizedNodeContainerBuilder<K,CK,CV,P> addChild(CV child);
+
     NormalizedNodeContainerBuilder<K,CK,CV,P> removeChild(CK key);
 }
index 905e7cd9e10fdcd36246ea11a6eb5305b202f68d..ac72aee1040de4b869164c4ec0f76b4a671815d1 100644 (file)
@@ -17,19 +17,20 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerAttrNode;
 
-abstract class AbstractImmutableDataContainerNodeAttrBuilder<I extends PathArgument, R extends DataContainerNode<I>> extends AbstractImmutableDataContainerNodeBuilder<I, R> implements DataContainerNodeAttrBuilder<I, R> {
+abstract class AbstractImmutableDataContainerNodeAttrBuilder<I extends PathArgument, R extends DataContainerNode<I>>
+        extends AbstractImmutableDataContainerNodeBuilder<I, R> implements DataContainerNodeAttrBuilder<I, R> {
     private Map<QName, String> attributes;
 
-    protected AbstractImmutableDataContainerNodeAttrBuilder() {
+    AbstractImmutableDataContainerNodeAttrBuilder() {
         this.attributes = Collections.emptyMap();
     }
 
-    protected AbstractImmutableDataContainerNodeAttrBuilder(final int sizeHint) {
+    AbstractImmutableDataContainerNodeAttrBuilder(final int sizeHint) {
         super(sizeHint);
         this.attributes = Collections.emptyMap();
     }
 
-    protected AbstractImmutableDataContainerNodeAttrBuilder(final AbstractImmutableDataContainerAttrNode<I> node) {
+    AbstractImmutableDataContainerNodeAttrBuilder(final AbstractImmutableDataContainerAttrNode<I> node) {
         super(node);
         this.attributes = node.getAttributes();
     }
@@ -39,13 +40,14 @@ abstract class AbstractImmutableDataContainerNodeAttrBuilder<I extends PathArgum
     }
 
     @Override
-    public DataContainerNodeAttrBuilder<I, R> withAttributes(final Map<QName, String> attributes){
+    public DataContainerNodeAttrBuilder<I, R> withAttributes(final Map<QName, String> attributes) {
         this.attributes = attributes;
         return this;
     }
 
     @Override
-    public DataContainerNodeAttrBuilder<I, R> withValue(final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
+    public DataContainerNodeAttrBuilder<I, R> withValue(
+            final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
         return (DataContainerNodeAttrBuilder<I, R>) super.withValue(value);
     }
 
index a83b908b91ce860daebae7be80397bc43c402971..64dc2e4175e936686a499abfebf6651a4b624601 100644 (file)
@@ -21,7 +21,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNo
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.CloneableMap;
 
-abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument, R extends DataContainerNode<I>> implements DataContainerNodeBuilder<I, R> {
+abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument, R extends DataContainerNode<I>>
+        implements DataContainerNodeBuilder<I, R> {
     private static final int DEFAULT_CAPACITY = 4;
     private Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> value;
     private I nodeIdentifier;
@@ -72,7 +73,8 @@ abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument,
 
     protected final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> buildValue() {
         if (value instanceof ModifiableMapPhase) {
-            return ((ModifiableMapPhase<PathArgument, DataContainerChild<? extends PathArgument, ?>>)value).toUnmodifiableMap();
+            return ((ModifiableMapPhase<PathArgument, DataContainerChild<? extends PathArgument, ?>>)value)
+                    .toUnmodifiableMap();
         }
 
         dirty = true;
@@ -82,9 +84,11 @@ abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument,
     private void checkDirty() {
         if (dirty) {
             if (value instanceof UnmodifiableMapPhase) {
-                value = ((UnmodifiableMapPhase<PathArgument, DataContainerChild<? extends PathArgument, ?>>) value).toModifiableMap();
+                value = ((UnmodifiableMapPhase<PathArgument, DataContainerChild<? extends PathArgument, ?>>) value)
+                        .toModifiableMap();
             } else if (value instanceof CloneableMap) {
-                value = ((CloneableMap<PathArgument, DataContainerChild<? extends PathArgument, ?>>) value).createMutableClone();
+                value = ((CloneableMap<PathArgument, DataContainerChild<? extends PathArgument, ?>>) value)
+                        .createMutableClone();
             } else {
                 value = new HashMap<>(value);
             }
@@ -93,7 +97,8 @@ abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument,
     }
 
     @Override
-    public DataContainerNodeBuilder<I, R> withValue(final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
+    public DataContainerNodeBuilder<I, R> withValue(
+            final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
         // TODO Replace or putAll ?
         for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : value) {
             withChild(dataContainerChild);
@@ -128,7 +133,8 @@ abstract class AbstractImmutableDataContainerNodeBuilder<I extends PathArgument,
     }
 
     @Override
-    public NormalizedNodeContainerBuilder<I, PathArgument, DataContainerChild<? extends PathArgument, ?>, R> removeChild(final PathArgument key) {
+    public NormalizedNodeContainerBuilder<I, PathArgument, DataContainerChild<? extends PathArgument, ?>, R>
+            removeChild(final PathArgument key) {
         return withoutChild(key);
     }
 }
index 5bd42380cdcb0743949710c981f16cb9c00b5641..d33db494217b05a0b5c23d44c8db44292357d546 100644 (file)
@@ -46,7 +46,7 @@ abstract class AbstractImmutableNormalizedNodeBuilder<I extends PathArgument, V,
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<I,V,R> withAttributes(final Map<QName, String> attributes){
+    public NormalizedNodeAttrBuilder<I,V,R> withAttributes(final Map<QName, String> attributes) {
         this.attributes = attributes;
         return this;
     }
index 2d7fe27deb8683e62a661614b7f106269a765e07..3095ebb2d718fc4c6e5231b53c01c65c66c0b5dd 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
 
-public class ImmutableAnyXmlNodeBuilder extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, DOMSource, AnyXmlNode> {
+public class ImmutableAnyXmlNodeBuilder
+        extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, DOMSource, AnyXmlNode> {
 
     public static NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> create() {
         return new ImmutableAnyXmlNodeBuilder();
@@ -26,9 +27,11 @@ public class ImmutableAnyXmlNodeBuilder extends AbstractImmutableNormalizedNodeB
         return new ImmutableXmlNode(getNodeIdentifier(), getValue(), getAttributes());
     }
 
-    private static final class ImmutableXmlNode extends AbstractImmutableNormalizedValueAttrNode<NodeIdentifier, DOMSource> implements AnyXmlNode {
+    private static final class ImmutableXmlNode
+            extends AbstractImmutableNormalizedValueAttrNode<NodeIdentifier, DOMSource> implements AnyXmlNode {
 
-        ImmutableXmlNode(final NodeIdentifier nodeIdentifier, final DOMSource value, final Map<QName, String> attributes) {
+        ImmutableXmlNode(final NodeIdentifier nodeIdentifier, final DOMSource value,
+                final Map<QName, String> attributes) {
             super(nodeIdentifier, value, attributes);
         }
     }
index d01fa420e310308a879c7270c6fc66244c0f2f03..d18a00b945c6a202f5a377fdbe25bbcd74f74406 100644 (file)
@@ -19,7 +19,8 @@ public final class ImmutableAnyXmlNodeSchemaAwareBuilder extends ImmutableAnyXml
         super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
     }
 
-    public static NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> create(final AnyXmlSchemaNode schema) {
+    public static NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> create(
+            final AnyXmlSchemaNode schema) {
         return new ImmutableAnyXmlNodeSchemaAwareBuilder(schema);
     }
 
@@ -29,7 +30,8 @@ public final class ImmutableAnyXmlNodeSchemaAwareBuilder extends ImmutableAnyXml
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+    public NormalizedNodeAttrBuilder<NodeIdentifier, DOMSource, AnyXmlNode> withNodeIdentifier(
+            final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 }
index 9d712787822d4bdef3f4a792631f05de25bc19a2..6c45323d60e579fecacd2aca639d791226a61a4c 100644 (file)
@@ -16,7 +16,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
 
-public class ImmutableAugmentationNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> {
+public class ImmutableAugmentationNodeBuilder
+        extends AbstractImmutableDataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> {
 
     protected ImmutableAugmentationNodeBuilder() {
         super();
@@ -38,7 +39,8 @@ public class ImmutableAugmentationNodeBuilder extends AbstractImmutableDataConta
         return new ImmutableAugmentationNodeBuilder(sizeHint);
     }
 
-    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(final AugmentationNode node) {
+    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(
+            final AugmentationNode node) {
         if (!(node instanceof ImmutableAugmentationNode)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -67,11 +69,12 @@ public class ImmutableAugmentationNodeBuilder extends AbstractImmutableDataConta
         return new ImmutableAugmentationNode(getNodeIdentifier(), buildValue());
     }
 
-    private static final class ImmutableAugmentationNode extends AbstractImmutableDataContainerNode<AugmentationIdentifier> implements AugmentationNode {
+    private static final class ImmutableAugmentationNode
+            extends AbstractImmutableDataContainerNode<AugmentationIdentifier> implements AugmentationNode {
 
-        ImmutableAugmentationNode(final AugmentationIdentifier nodeIdentifier, final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children) {
+        ImmutableAugmentationNode(final AugmentationIdentifier nodeIdentifier,
+                final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children) {
             super(children, nodeIdentifier);
         }
     }
-
 }
index e445158cd23c86f4fdbdabec6bbbb49a48705951..363bfee9a7f5a62e787d5bd0a9fe6e471aa16100 100644 (file)
@@ -25,18 +25,19 @@ public class ImmutableAugmentationNodeSchemaAwareBuilder extends ImmutableAugmen
     }
 
     @Override
-    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withNodeIdentifier(final AugmentationIdentifier nodeIdentifier) {
+    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withNodeIdentifier(
+            final AugmentationIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 
     @Override
-    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withChild(final DataContainerChild<?, ?> child) {
+    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withChild(
+            final DataContainerChild<?, ?> child) {
         return super.withChild(validator.validateChild(child));
     }
 
-    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(final AugmentationSchema schema) {
+    public static DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(
+            final AugmentationSchema schema) {
         return new ImmutableAugmentationNodeSchemaAwareBuilder(schema);
     }
-
-
 }
index 160e7f80b6742eec4ac76d4d8a02515310688e74..7022d3fe8b8faa4152e02df6652a89630a731959 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableD
 public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, ChoiceNode> {
 
     protected ImmutableChoiceNodeBuilder() {
-        super();
+
     }
 
     protected ImmutableChoiceNodeBuilder(final int sizeHint) {
@@ -50,7 +50,8 @@ public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNo
         return new ImmutableChoiceNode(getNodeIdentifier(), buildValue());
     }
 
-    private static final class ImmutableChoiceNode extends AbstractImmutableDataContainerNode<NodeIdentifier> implements ChoiceNode {
+    private static final class ImmutableChoiceNode extends AbstractImmutableDataContainerNode<NodeIdentifier>
+            implements ChoiceNode {
 
         ImmutableChoiceNode(final NodeIdentifier nodeIdentifier,
                 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children) {
index 037e406a3d1c6356634580792b3b246e13e36230..7c50a74d544c7594060cd49057c6287959556e9a 100644 (file)
@@ -30,7 +30,8 @@ public class ImmutableChoiceNodeSchemaAwareBuilder extends ImmutableChoiceNodeBu
     }
 
     @Override
-    public DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+    public DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> withNodeIdentifier(
+            final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 
index 56a25bc19ac01b1935c3c060331dbc83021b2060..aad67686f3fb2b898abac94136da30f22272f016 100644 (file)
@@ -16,10 +16,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerAttrNode;
 
-public class ImmutableContainerNodeBuilder extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> {
+public class ImmutableContainerNodeBuilder
+        extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> {
 
     protected ImmutableContainerNodeBuilder() {
-        super();
+
     }
 
     protected ImmutableContainerNodeBuilder(final int sizeHint) {
@@ -50,10 +51,10 @@ public class ImmutableContainerNodeBuilder extends AbstractImmutableDataContaine
         return new ImmutableContainerNode(getNodeIdentifier(), buildValue(), getAttributes());
     }
 
-    protected static final class ImmutableContainerNode extends AbstractImmutableDataContainerAttrNode<NodeIdentifier> implements ContainerNode {
+    protected static final class ImmutableContainerNode extends AbstractImmutableDataContainerAttrNode<NodeIdentifier>
+            implements ContainerNode {
 
-        ImmutableContainerNode(
-                final NodeIdentifier nodeIdentifier,
+        ImmutableContainerNode(final NodeIdentifier nodeIdentifier,
                 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children,
                 final Map<QName, String> attributes) {
             super(children, nodeIdentifier, attributes);
index af75438b977d178ae538beab41457f3fb71485cd..9143a36c4f3db2ea8f1d392ddcb0686b00b6b2ee 100644 (file)
@@ -23,7 +23,8 @@ public final class ImmutableContainerNodeSchemaAwareBuilder extends ImmutableCon
         super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
     }
 
-    private ImmutableContainerNodeSchemaAwareBuilder(final ContainerSchemaNode schema, final ImmutableContainerNode node) {
+    private ImmutableContainerNodeSchemaAwareBuilder(final ContainerSchemaNode schema,
+            final ImmutableContainerNode node) {
         super(node);
         this.validator = new DataNodeContainerValidator(schema);
         super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
@@ -33,7 +34,8 @@ public final class ImmutableContainerNodeSchemaAwareBuilder extends ImmutableCon
         return new ImmutableContainerNodeSchemaAwareBuilder(schema);
     }
 
-    public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> create(final ContainerSchemaNode schema, final ContainerNode node) {
+    public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> create(final ContainerSchemaNode schema,
+            final ContainerNode node) {
         if (!(node instanceof ImmutableContainerNode)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -41,7 +43,8 @@ public final class ImmutableContainerNodeSchemaAwareBuilder extends ImmutableCon
     }
 
     @Override
-    public DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+    public DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> withNodeIdentifier(
+            final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 
index adab1e3d749dd48e37715beb46ae9770702081f0..258d408bfaaf6e7e8d0f4af7a90223791457aaac 100644 (file)
@@ -14,7 +14,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
 
-public class ImmutableLeafNodeBuilder<T> extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> {
+public class ImmutableLeafNodeBuilder<T>
+        extends AbstractImmutableNormalizedNodeBuilder<NodeIdentifier, T, LeafNode<T>> {
 
     public static <T> NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> create() {
         return new ImmutableLeafNodeBuilder<>();
index 786ea52d179897f74223f2fc7e63cccd0618e047..fdc174099a756979306cae2e06681a2d84171882 100644 (file)
@@ -24,12 +24,13 @@ public final class ImmutableLeafNodeSchemaAwareBuilder<T> extends ImmutableLeafN
 
     @Override
     public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withValue(final T value) {
-//        TODO check value type
+        // TODO: check value type
         return super.withValue(value);
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
+    public NormalizedNodeAttrBuilder<NodeIdentifier, T, LeafNode<T>> withNodeIdentifier(
+            final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 }
index 7e3505b53668a3e9aea0b351f47d96dbe780ceed..63e4470878ce55d28a5931c27d134697103e6326 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithV
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
 
-public class ImmutableLeafSetEntryNodeBuilder<T> extends AbstractImmutableNormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> {
+public class ImmutableLeafSetEntryNodeBuilder<T>
+        extends AbstractImmutableNormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> {
 
     public static <T> ImmutableLeafSetEntryNodeBuilder<T> create() {
         return new ImmutableLeafSetEntryNodeBuilder<>();
@@ -26,9 +27,11 @@ public class ImmutableLeafSetEntryNodeBuilder<T> extends AbstractImmutableNormal
         return new ImmutableLeafSetEntryNode<>(getNodeIdentifier(), getValue(), getAttributes());
     }
 
-    private static final class ImmutableLeafSetEntryNode<T> extends AbstractImmutableNormalizedValueAttrNode<NodeWithValue, T> implements LeafSetEntryNode<T> {
+    private static final class ImmutableLeafSetEntryNode<T>
+            extends AbstractImmutableNormalizedValueAttrNode<NodeWithValue, T> implements LeafSetEntryNode<T> {
 
-        ImmutableLeafSetEntryNode(final NodeWithValue nodeIdentifier, final T value, final Map<QName, String> attributes) {
+        ImmutableLeafSetEntryNode(final NodeWithValue nodeIdentifier, final T value,
+                final Map<QName, String> attributes) {
             super(nodeIdentifier, value, attributes);
             Preconditions.checkArgument(Objects.deepEquals(nodeIdentifier.getValue(), value),
                     "Node identifier contains different value: %s than value itself: %s", nodeIdentifier, value);
index 248ee28411ecb891c84807858db1caf9f6a9c354..d9a7cbc66f2999e859478b20021b31493ca8d332 100644 (file)
@@ -21,7 +21,8 @@ public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends Immuta
         this.schema = Preconditions.checkNotNull(schema);
     }
 
-    public static <T> NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema) {
+    public static <T> NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(
+            final LeafListSchemaNode schema) {
         return new ImmutableLeafSetEntryNodeSchemaAwareBuilder<>(schema);
     }
 
@@ -33,7 +34,8 @@ public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends Immuta
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeWithValue nodeIdentifier) {
+    public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(
+            final NodeWithValue nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 
index 72572704e348497dfaa8df6b50357bc44934a5c8..6c05729de8d352cd0cd58fc311a1beb4326c6792 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableN
 
 public class ImmutableLeafSetNodeBuilder<T> implements ListNodeBuilder<T, LeafSetEntryNode<T>> {
     private static final int DEFAULT_CAPACITY = 4;
+
     private final Map<NodeWithValue, LeafSetEntryNode<T>> value;
     private NodeIdentifier nodeIdentifier;
 
@@ -111,13 +112,14 @@ public class ImmutableLeafSetNodeBuilder<T> implements ListNodeBuilder<T, LeafSe
         return withChildValue(value, Collections.emptyMap());
     }
 
-    protected final static class ImmutableLeafSetNode<T> extends
+    protected static final class ImmutableLeafSetNode<T> extends
             AbstractImmutableNormalizedValueNode<NodeIdentifier, Collection<LeafSetEntryNode<T>>> implements
             Immutable, LeafSetNode<T> {
 
         private final Map<NodeWithValue, LeafSetEntryNode<T>> children;
 
-        ImmutableLeafSetNode(final NodeIdentifier nodeIdentifier, final Map<NodeWithValue, LeafSetEntryNode<T>> children) {
+        ImmutableLeafSetNode(final NodeIdentifier nodeIdentifier,
+                final Map<NodeWithValue, LeafSetEntryNode<T>> children) {
             super(nodeIdentifier, UnmodifiableCollection.create(children.values()));
             this.children = children;
         }
@@ -145,8 +147,8 @@ public class ImmutableLeafSetNodeBuilder<T> implements ListNodeBuilder<T, LeafSe
     }
 
     @Override
-    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, LeafSetEntryNode<T>, LeafSetNode<T>> removeChild(
-            final PathArgument key) {
+    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, LeafSetEntryNode<T>, LeafSetNode<T>>
+            removeChild(final PathArgument key) {
         return withoutChild(key);
     }
 
index ba0d64a1e3fc7943e165098ce4c0810e77a0295d..82209f830f2169a2229b4b2b7833e32e8d7af59c 100644 (file)
@@ -7,37 +7,37 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
-import com.google.common.collect.Sets;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 
-import com.google.common.base.Preconditions;
-
 public final class ImmutableLeafSetNodeSchemaAwareBuilder<T> extends ImmutableLeafSetNodeBuilder<T> {
 
     private final LeafListSchemaNode schema;
 
     private ImmutableLeafSetNodeSchemaAwareBuilder(final LeafListSchemaNode schema) {
         this.schema = Preconditions.checkNotNull(schema);
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
     }
 
     public ImmutableLeafSetNodeSchemaAwareBuilder(final LeafListSchemaNode schema, final ImmutableLeafSetNode<T> node) {
         super(node);
         this.schema = Preconditions.checkNotNull(schema);
         // FIXME: Preconditions.checkArgument(schema.getQName().equals(node.getIdentifier()));
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
     }
 
     public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema) {
         return new ImmutableLeafSetNodeSchemaAwareBuilder<>(schema);
     }
 
-    public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema, final LeafSetNode<T> node) {
+    public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema,
+            final LeafSetNode<T> node) {
         if (!(node instanceof ImmutableLeafSetNode<?>)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -56,12 +56,13 @@ public final class ImmutableLeafSetNodeSchemaAwareBuilder<T> extends ImmutableLe
         Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()),
                 "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType());
         // TODO check value type using TypeProvider ?
-        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+            schema, Collections.singleton(schema.getQName()));
         return super.withChild(child);
     }
 
     @Override
-    public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier) {
+    public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 }
index e6a7880c3e2595bdc685ee1fff3af63559d597f8..2164bb4df232c30e58851c8d4fd6f93b87c3a760 100644 (file)
@@ -25,7 +25,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableD
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> {
+public class ImmutableMapEntryNodeBuilder
+        extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> {
     private static final Logger LOG = LoggerFactory.getLogger(ImmutableMapEntryNodeBuilder.class);
     protected final Map<QName, PathArgument> childrenQNamesToPaths;
 
@@ -53,7 +54,8 @@ public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainer
         return new ImmutableMapEntryNodeBuilder(sizeHint);
     }
 
-    public static DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> create(final MapEntryNode node) {
+    public static DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> create(
+            final MapEntryNode node) {
         if (!(node instanceof ImmutableMapEntryNode)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -61,7 +63,8 @@ public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainer
         return new ImmutableMapEntryNodeBuilder((ImmutableMapEntryNode)node);
     }
 
-    private static void fillQnames(final Iterable<DataContainerChild<? extends PathArgument, ?>> iterable, final Map<QName, PathArgument> out) {
+    private static void fillQnames(final Iterable<DataContainerChild<? extends PathArgument, ?>> iterable,
+            final Map<QName, PathArgument> out) {
         for (final DataContainerChild<? extends PathArgument, ?> childId : iterable) {
             final PathArgument identifier = childId.getIdentifier();
 
@@ -76,7 +79,8 @@ public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainer
 
 
     @Override
-    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withValue(final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
+    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withValue(
+            final Collection<DataContainerChild<? extends PathArgument, ?>> value) {
         fillQnames(value, childrenQNamesToPaths);
         return super.withValue(value);
     }
@@ -86,7 +90,8 @@ public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainer
     }
 
     @Override
-    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withChild(final DataContainerChild<?, ?> child) {
+    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withChild(
+            final DataContainerChild<?, ?> child) {
         // Augmentation nodes cannot be keys, and do not have to be present in childrenQNamesToPaths map
         if (!isAugment(child.getIdentifier())) {
             childrenQNamesToPaths.put(child.getNodeType(), child.getIdentifier());
@@ -106,17 +111,20 @@ public class ImmutableMapEntryNodeBuilder extends AbstractImmutableDataContainer
                 LOG.debug("Adding leaf {} implied by key {}", leaf, key);
                 withChild(leaf);
             } else {
-                DataValidationException.checkListKey(getNodeIdentifier(), key.getKey(), key.getValue(), childNode.getValue());
+                DataValidationException.checkListKey(getNodeIdentifier(), key.getKey(), key.getValue(),
+                    childNode.getValue());
             }
         }
 
         return new ImmutableMapEntryNode(getNodeIdentifier(), buildValue(), getAttributes());
     }
 
-    private static final class ImmutableMapEntryNode extends AbstractImmutableDataContainerAttrNode<NodeIdentifierWithPredicates> implements MapEntryNode {
+    private static final class ImmutableMapEntryNode
+            extends AbstractImmutableDataContainerAttrNode<NodeIdentifierWithPredicates> implements MapEntryNode {
 
         ImmutableMapEntryNode(final NodeIdentifierWithPredicates nodeIdentifier,
-                final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children, final Map<QName, String> attributes) {
+                final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children,
+                final Map<QName, String> attributes) {
             super(children, nodeIdentifier, attributes);
         }
     }
index fd890e57ee04c0949caaa7981280c0e65eb482fa..36ee87875cce637c9678e5398dde5edab972116e 100644 (file)
@@ -20,12 +20,12 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataN
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
-public final class ImmutableMapEntryNodeSchemaAwareBuilder extends ImmutableMapEntryNodeBuilder{
+public final class ImmutableMapEntryNodeSchemaAwareBuilder extends ImmutableMapEntryNodeBuilder {
 
     private final ListSchemaNode schema;
     private final DataNodeContainerValidator validator;
 
-    protected ImmutableMapEntryNodeSchemaAwareBuilder(final ListSchemaNode schema) {
+    ImmutableMapEntryNodeSchemaAwareBuilder(final ListSchemaNode schema) {
         this.schema = Preconditions.checkNotNull(schema);
         this.validator = new DataNodeContainerValidator(schema);
     }
@@ -36,7 +36,8 @@ public final class ImmutableMapEntryNodeSchemaAwareBuilder extends ImmutableMapE
     }
 
     @Override
-    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withChild(final DataContainerChild<?, ?> child) {
+    public DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> withChild(
+            final DataContainerChild<?, ?> child) {
         validator.validateChild(child.getIdentifier());
         return super.withChild(child);
     }
@@ -48,7 +49,7 @@ public final class ImmutableMapEntryNodeSchemaAwareBuilder extends ImmutableMapE
     }
 
     /**
-     * Build map entry node identifier from schema, and provided children
+     * Build map entry node identifier from schema and provided children.
      */
     private NodeIdentifierWithPredicates constructNodeIdentifier() {
         Collection<QName> keys = schema.getKeyDefinition();
@@ -68,8 +69,8 @@ public final class ImmutableMapEntryNodeSchemaAwareBuilder extends ImmutableMapE
         return new NodeIdentifierWithPredicates(schema.getQName(), keysToValues);
     }
 
-    public static DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> create(final ListSchemaNode schema) {
+    public static DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> create(
+            final ListSchemaNode schema) {
         return new ImmutableMapEntryNodeSchemaAwareBuilder(schema);
     }
-
 }
index bb4217a5631ce9f6658a257004e97baf5a06a59d..783a3b7188a22663e8dc8a0b8feff102f5c0a952 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Map;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.util.MapAdaptor;
 import org.opendaylight.yangtools.util.UnmodifiableCollection;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -27,6 +26,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableN
 
 public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNode, MapNode> {
     private static final int DEFAULT_CAPACITY = 4;
+
     private final Map<NodeIdentifierWithPredicates, MapEntryNode> value;
     private NodeIdentifier nodeIdentifier;
 
@@ -109,18 +109,20 @@ public class ImmutableMapNodeBuilder implements CollectionNodeBuilder<MapEntryNo
         return withoutChild(key);
     }
 
-    protected static final class ImmutableMapNode extends AbstractImmutableNormalizedNode<YangInstanceIdentifier.NodeIdentifier, Collection<MapEntryNode>> implements Immutable,MapNode {
+    protected static final class ImmutableMapNode
+            extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<MapEntryNode>>
+            implements Immutable, MapNode {
 
-        private final Map<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> children;
+        private final Map<NodeIdentifierWithPredicates, MapEntryNode> children;
 
-        ImmutableMapNode(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier,
-                         final Map<YangInstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> children) {
+        ImmutableMapNode(final NodeIdentifier nodeIdentifier,
+                         final Map<NodeIdentifierWithPredicates, MapEntryNode> children) {
             super(nodeIdentifier);
             this.children = children;
         }
 
         @Override
-        public Optional<MapEntryNode> getChild(final YangInstanceIdentifier.NodeIdentifierWithPredicates child) {
+        public Optional<MapEntryNode> getChild(final NodeIdentifierWithPredicates child) {
             return Optional.fromNullable(children.get(child));
         }
 
index 59ac2397a92588aaac785af0814713f6c23de204..f4af8a7fdcf0d64017f741a4ff4d4505085663d6 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
+import java.util.Collections;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
@@ -45,7 +45,8 @@ public class ImmutableMapNodeSchemaAwareBuilder extends ImmutableMapNodeBuilder
 
     @Override
     public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(final MapEntryNode child) {
-        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+            schema, Collections.singleton(schema.getQName()));
         return super.withChild(child);
     }
 
index d2558319dd3114c35cf8d6326bf4af8359eb1c92..dd2fd895cfce57815febe3cc2ffddda4bb386595 100644 (file)
@@ -128,6 +128,11 @@ public class ImmutableOrderedLeafSetNodeBuilder<T> implements ListNodeBuilder<T,
             return Optional.fromNullable(children.get(child));
         }
 
+        @Override
+        public LeafSetEntryNode<T> getChild(final int position) {
+            return Iterables.get(children.values(), position);
+        }
+
         @Override
         protected int valueHashCode() {
             return children.hashCode();
@@ -142,11 +147,6 @@ public class ImmutableOrderedLeafSetNodeBuilder<T> implements ListNodeBuilder<T,
             return children.equals(((ImmutableOrderedLeafSetNode<?>) other).children);
         }
 
-        @Override
-        public LeafSetEntryNode<T> getChild(final int position) {
-            return Iterables.get(children.values(), position);
-        }
-
         @Override
         public int getSize() {
             return children.size();
@@ -165,9 +165,8 @@ public class ImmutableOrderedLeafSetNodeBuilder<T> implements ListNodeBuilder<T,
     }
 
     @Override
-    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, LeafSetEntryNode<T>, LeafSetNode<T>> removeChild(
-            final PathArgument key) {
+    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, LeafSetEntryNode<T>, LeafSetNode<T>>
+            removeChild(final PathArgument key) {
         return withoutChild(key);
     }
-
 }
index a3ad5501f56742b0d81bda2268b61930c9cdb6a6..d016754eccb04ffc06c2bd004f34d3c68eb19703 100644 (file)
@@ -7,37 +7,38 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 
-import com.google.common.base.Preconditions;
-
 public final class ImmutableOrderedLeafSetNodeSchemaAwareBuilder<T> extends ImmutableOrderedLeafSetNodeBuilder<T> {
 
     private final LeafListSchemaNode schema;
 
     private ImmutableOrderedLeafSetNodeSchemaAwareBuilder(final LeafListSchemaNode schema) {
         this.schema = Preconditions.checkNotNull(schema);
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
     }
 
-    public ImmutableOrderedLeafSetNodeSchemaAwareBuilder(final LeafListSchemaNode schema, final ImmutableOrderedLeafSetNode<T> node) {
+    public ImmutableOrderedLeafSetNodeSchemaAwareBuilder(final LeafListSchemaNode schema,
+            final ImmutableOrderedLeafSetNode<T> node) {
         super(node);
         this.schema = Preconditions.checkNotNull(schema);
         // FIXME: Preconditions.checkArgument(schema.getQName().equals(node.getIdentifier()));
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        super.withNodeIdentifier(new NodeIdentifier(schema.getQName()));
     }
 
     public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema) {
         return new ImmutableOrderedLeafSetNodeSchemaAwareBuilder<>(schema);
     }
 
-    public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema, final LeafSetNode<T> node) {
+    public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema,
+            final LeafSetNode<T> node) {
         if (!(node instanceof ImmutableOrderedLeafSetNode<?>)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -56,12 +57,13 @@ public final class ImmutableOrderedLeafSetNodeSchemaAwareBuilder<T> extends Immu
         Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()),
                 "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType());
         // TODO check value type using TypeProvider ?
-        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+            schema, Sets.newHashSet(schema.getQName()));
         return super.withChild(child);
     }
 
     @Override
-    public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier) {
+    public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeIdentifier nodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 }
index ec994bcc56158384a54c85b0ec5a76288be1c486..c95be10d42a29fcad339c82b09f53a85c60ca116 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableN
 
 public class ImmutableOrderedMapNodeBuilder implements CollectionNodeBuilder<MapEntryNode, OrderedMapNode> {
     private static final int DEFAULT_CAPACITY = 4;
+
     private Map<NodeIdentifierWithPredicates, MapEntryNode> value;
     private NodeIdentifier nodeIdentifier;
     private boolean dirty;
@@ -122,7 +123,9 @@ public class ImmutableOrderedMapNodeBuilder implements CollectionNodeBuilder<Map
         return withoutChild(key);
     }
 
-    protected static final class ImmutableOrderedMapNode extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<MapEntryNode>> implements Immutable, OrderedMapNode {
+    protected static final class ImmutableOrderedMapNode
+            extends AbstractImmutableNormalizedNode<NodeIdentifier, Collection<MapEntryNode>>
+            implements Immutable, OrderedMapNode {
 
         private final Map<NodeIdentifierWithPredicates, MapEntryNode> children;
 
@@ -137,6 +140,11 @@ public class ImmutableOrderedMapNodeBuilder implements CollectionNodeBuilder<Map
             return Optional.fromNullable(children.get(child));
         }
 
+        @Override
+        public MapEntryNode getChild(final int position) {
+            return Iterables.get(children.values(), position);
+        }
+
         @Override
         protected int valueHashCode() {
             return children.hashCode();
@@ -147,11 +155,6 @@ public class ImmutableOrderedMapNodeBuilder implements CollectionNodeBuilder<Map
             return children.equals(((ImmutableOrderedMapNode) other).children);
         }
 
-        @Override
-        public MapEntryNode getChild(final int position) {
-            return Iterables.get(children.values(), position);
-        }
-
         @Override
         public int getSize() {
             return children.size();
index a4f7c2c45d4987cd10ed04edd62e3319ac6808c3..54ae5e5e99583f99bc13b4e2cd8103a7c29c9713 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
+import java.util.Collections;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
@@ -26,7 +26,8 @@ public class ImmutableOrderedMapNodeSchemaAwareBuilder extends ImmutableOrderedM
         super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
     }
 
-    protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema, final ImmutableOrderedMapNode node) {
+    protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema,
+            final ImmutableOrderedMapNode node) {
         super(node);
         this.schema = Preconditions.checkNotNull(schema);
         super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
@@ -47,7 +48,8 @@ public class ImmutableOrderedMapNodeSchemaAwareBuilder extends ImmutableOrderedM
 
     @Override
     public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) {
-        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+            schema, Collections.singleton(schema.getQName()));
         return super.withChild(child);
     }
 
index ed133b9c4e28422fb851fa656aab99595c9e69ce..cc147278544476e604201f03f3b6dd713a7e3551 100644 (file)
@@ -16,10 +16,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerAttrNode;
 
-public class ImmutableUnkeyedListEntryNodeBuilder extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> {
+public class ImmutableUnkeyedListEntryNodeBuilder
+        extends AbstractImmutableDataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> {
 
     protected ImmutableUnkeyedListEntryNodeBuilder() {
-        super();
+
     }
 
     protected ImmutableUnkeyedListEntryNodeBuilder(final int sizeHint) {
@@ -38,7 +39,8 @@ public class ImmutableUnkeyedListEntryNodeBuilder extends AbstractImmutableDataC
         return new ImmutableUnkeyedListEntryNodeBuilder(sizeHint);
     }
 
-    public static DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> create(final UnkeyedListEntryNode node) {
+    public static DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> create(
+            final UnkeyedListEntryNode node) {
         if (!(node instanceof ImmutableUnkeyedListEntryNode)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
         }
@@ -50,10 +52,10 @@ public class ImmutableUnkeyedListEntryNodeBuilder extends AbstractImmutableDataC
         return new ImmutableUnkeyedListEntryNode(getNodeIdentifier(), buildValue(), getAttributes());
     }
 
-    protected static final class ImmutableUnkeyedListEntryNode extends AbstractImmutableDataContainerAttrNode<NodeIdentifier> implements UnkeyedListEntryNode {
+    protected static final class ImmutableUnkeyedListEntryNode
+            extends AbstractImmutableDataContainerAttrNode<NodeIdentifier> implements UnkeyedListEntryNode {
 
-        ImmutableUnkeyedListEntryNode(
-                final NodeIdentifier nodeIdentifier,
+        ImmutableUnkeyedListEntryNode(final NodeIdentifier nodeIdentifier,
                 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children,
                 final Map<QName, String> attributes) {
             super(children, nodeIdentifier, attributes);
index fb47782805c9e96ba17746fe3d969822feaa4b79..e0b4af5720cbb633b4e3bf6fe363297032c0ebeb 100644 (file)
@@ -35,6 +35,7 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
 
     protected ImmutableUnkeyedListNodeBuilder(final ImmutableUnkeyedListNode node) {
         this.nodeIdentifier = node.getIdentifier();
+        // FIXME: clean this up, notably reuse unmodified lists
         this.value = new LinkedList<>();
         Iterables.addAll(value, node.getValue());
         this.dirty = true;
@@ -78,10 +79,11 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
     }
 
     @Override
-    public CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> withValue(final Collection<UnkeyedListEntryNode> value) {
+    public CollectionNodeBuilder<UnkeyedListEntryNode, UnkeyedListNode> withValue(
+            final Collection<UnkeyedListEntryNode> value) {
         // TODO replace or putAll ?
-        for (final UnkeyedListEntryNode UnkeyedListEntryNode : value) {
-            withChild(UnkeyedListEntryNode);
+        for (final UnkeyedListEntryNode node : value) {
+            withChild(node);
         }
 
         return this;
@@ -109,8 +111,8 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
     }
 
     @Override
-    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, UnkeyedListEntryNode, UnkeyedListNode> removeChild(
-            final PathArgument key) {
+    public NormalizedNodeContainerBuilder<NodeIdentifier, PathArgument, UnkeyedListEntryNode, UnkeyedListNode>
+            removeChild(final PathArgument key) {
         return withoutChild(key);
     }
 
index 9d1d4b5d0f9df2668b648bbe98f5a20f7df8f383..ddb14a2c255a2d1a2603fd6ca52bc3164cdc93fd 100644 (file)
@@ -31,7 +31,8 @@ public class ImmutableYangModeledAnyXmlNodeBuilder extends
         this.contentSchema = yangModeledAnyXMLSchemaNode.getSchemaOfAnyXmlData();
     }
 
-    private ImmutableYangModeledAnyXmlNodeBuilder(final YangModeledAnyXmlSchemaNode yangModeledAnyXMLSchemaNode, final int sizeHint) {
+    private ImmutableYangModeledAnyXmlNodeBuilder(final YangModeledAnyXmlSchemaNode yangModeledAnyXMLSchemaNode,
+            final int sizeHint) {
         super(sizeHint);
         Preconditions.checkNotNull(yangModeledAnyXMLSchemaNode, "Yang modeled any xml node must not be null.");
         super.withNodeIdentifier(NodeIdentifier.create(yangModeledAnyXMLSchemaNode.getQName()));
@@ -62,7 +63,8 @@ public class ImmutableYangModeledAnyXmlNodeBuilder extends
                 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> value,
                 final Map<QName, String> attributes, final ContainerSchemaNode contentSchema) {
             super(value, nodeIdentifier, attributes);
-            this.contentSchema = Preconditions.checkNotNull(contentSchema, "Schema of yang modeled anyXml content cannot be null.");
+            this.contentSchema = Preconditions.checkNotNull(contentSchema,
+                "Schema of yang modeled anyXml content cannot be null.");
         }
 
         @Nonnull
index 617083f98ac94ea800c57de9ac8819ee95b85168..36bedc5e1d715ca52a0402e656a6c786ba6c20bb 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
 import java.util.HashSet;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -26,10 +25,9 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
  * General validator for container like statements, e.g. container, list-entry, choice, augment
  */
 public class DataNodeContainerValidator {
-
+    private final Set<AugmentationIdentifier> augments = new HashSet<>();
     private final DataNodeContainer schema;
     private final Set<QName> childNodes;
-    private final Set<AugmentationIdentifier> augments = new HashSet<>();
 
     public DataNodeContainerValidator(final DataNodeContainer schema) {
         this.schema = Preconditions.checkNotNull(schema, "Schema was null");
@@ -61,10 +59,11 @@ public class DataNodeContainerValidator {
     }
 
     /**
-     * Map all direct child nodes. Skip augments since they have no qname. List cases since cases do not exist in NormalizedNode API.
+     * Map all direct child nodes. Skip augments since they have no qname. List cases since cases do not exist in
+     * NormalizedNode API.
      */
     private static Set<QName> getChildNodes(final DataNodeContainer nodeContainer) {
-        Set<QName> allChildNodes = Sets.newHashSet();
+        Set<QName> allChildNodes = new HashSet<>();
 
         for (DataSchemaNode childSchema : nodeContainer.getChildNodes()) {
             if (childSchema instanceof ChoiceCaseNode) {
@@ -76,5 +75,4 @@ public class DataNodeContainerValidator {
 
         return allChildNodes;
     }
-
 }
index 9b1caf0d8f5a89eb838ac8d00a6f7b492b5cce76..4e23ca841d37ad4d76ab2def7e43b901eb0fd554 100644 (file)
@@ -46,21 +46,23 @@ public class DataValidationException extends RuntimeException {
         }
     }
 
-    public static void checkLegalData(final boolean isLegal, final String messageTemplate, final Object... messageAttrs) {
+    public static void checkLegalData(final boolean isLegal, final String messageTemplate,
+            final Object... messageAttrs) {
         if (!isLegal) {
             throw new DataValidationException(String.format(messageTemplate, messageAttrs));
         }
     }
 
-    public static void checkListKey(final NodeIdentifierWithPredicates nodeId, final QName keyQName, final Object expected, final Object actual) {
+    public static void checkListKey(final NodeIdentifierWithPredicates nodeId, final QName keyQName,
+            final Object expected, final Object actual) {
         // Objects.equals() does not deal with arrays, but is faster
         if (!Objects.equals(expected, actual) && !Objects.deepEquals(expected, actual)) {
             throw new IllegalListKeyException(keyQName, nodeId, actual, expected);
         }
     }
 
-    public static void checkListKey(final DataContainerChild<?, ?> childNode, final Map<QName, Object> keyValues, final QName keyQName,
-            final NodeIdentifierWithPredicates nodeId) {
+    public static void checkListKey(final DataContainerChild<?, ?> childNode, final Map<QName, Object> keyValues,
+            final QName keyQName, final NodeIdentifierWithPredicates nodeId) {
         checkListKey(childNode, keyQName, nodeId);
 
         final Object expected = keyValues.get(keyQName);
@@ -69,7 +71,8 @@ public class DataValidationException extends RuntimeException {
         checkListKey(nodeId, keyQName, expected, actual);
     }
 
-    public static void checkListKey(final DataContainerChild<?, ?> childNode, final QName keyQName, final NodeIdentifierWithPredicates nodeId) {
+    public static void checkListKey(final DataContainerChild<?, ?> childNode, final QName keyQName,
+            final NodeIdentifierWithPredicates nodeId) {
         if (childNode == null) {
             throw new IllegalListKeyException(keyQName, nodeId);
         }
@@ -88,21 +91,24 @@ public class DataValidationException extends RuntimeException {
             super(String.format("Unknown child node: %s, not detected in choice: %s", child, schema));
         }
 
-        private IllegalChildException(final PathArgument child, final DataSchemaNode schema, final Set<QName> childNodes) {
-            super(String.format("Unknown child node: %s, does not belong to: %s as a child. "
-                    + "Child nodes: %s", child, schema, childNodes));
+        private IllegalChildException(final PathArgument child, final DataSchemaNode schema,
+                final Set<QName> childNodes) {
+            super(String.format("Unknown child node: %s, does not belong to: %s as a child. Child nodes: %s", child,
+                schema, childNodes));
         }
     }
 
     private static final class IllegalListKeyException extends DataValidationException {
         private static final long serialVersionUID = 1L;
 
-        private IllegalListKeyException(final QName keyQName, final NodeIdentifierWithPredicates id) {
+        IllegalListKeyException(final QName keyQName, final NodeIdentifierWithPredicates id) {
             super(String.format("Key value not present for key: %s, in: %s", keyQName, id));
         }
 
-        private IllegalListKeyException(final QName keyQName, final NodeIdentifierWithPredicates id, final Object actualValue, final Object expectedValue) {
-            super(String.format("Illegal value for key: %s, in: %s, actual value: %s, expected value from key: %s", keyQName, id, actualValue, expectedValue));
+        IllegalListKeyException(final QName keyQName, final NodeIdentifierWithPredicates id, final Object actualValue,
+                final Object expectedValue) {
+            super(String.format("Illegal value for key: %s, in: %s, actual value: %s, expected value from key: %s",
+                keyQName, id, actualValue, expectedValue));
         }
     }
 }
index f2677571f04b717708776dea0567f4154b6e7da2..aad07e89e2f8b227dff950234840f5ef34667462 100644 (file)
@@ -46,6 +46,7 @@ public abstract class AbstractImmutableDataContainerNode<K extends PathArgument>
     /**
      * DO NOT USE THIS METHOD.
      *
+     * <p>
      * This is an implementation-internal API and no outside users should use it. If you do,
      * you are asking for trouble, as the returned object is not guaranteed to conform to
      * java.util.Map interface.
index 2805260f3e7b7d59567cf271fce3a5a9a8fc8172..13ef48fc1267426450a4aeb31af57824ce21995a 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-public abstract class AbstractImmutableNormalizedNode<K extends PathArgument,V> implements NormalizedNode<K, V>, Immutable {
+public abstract class AbstractImmutableNormalizedNode<K extends PathArgument,V> implements NormalizedNode<K, V>,
+        Immutable {
     private final K nodeIdentifier;
 
     protected AbstractImmutableNormalizedNode(final K nodeIdentifier) {
@@ -42,6 +43,7 @@ public abstract class AbstractImmutableNormalizedNode<K extends PathArgument,V>
     }
 
     protected abstract boolean valueEquals(AbstractImmutableNormalizedNode<?, ?> other);
+
     protected abstract int valueHashCode();
 
     @Override
index bbc797f59b4c4130a2cffd068d0ca32f34078285..61d9b8fabbff10450ff16d6597d97327bd498fb3 100644 (file)
@@ -21,7 +21,8 @@ public abstract class AbstractImmutableNormalizedValueAttrNode<K extends PathArg
 
     private final Map<QName, String> attributes;
 
-    protected AbstractImmutableNormalizedValueAttrNode(final K nodeIdentifier, final V value, final Map<QName, String> attributes) {
+    protected AbstractImmutableNormalizedValueAttrNode(final K nodeIdentifier, final V value,
+            final Map<QName, String> attributes) {
         super(nodeIdentifier, value);
         this.attributes = ImmutableMap.copyOf(attributes);
     }
index 877efba347447042e8a716978a27fd0086ed7084..ec114866f01045ef5c232a2f8a75372e286948e7 100644 (file)
@@ -23,7 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
  * Internal equivalent of {@link Collections}' unmodifiable Map. It does not retain
  * keySet/entrySet references, thus lowering the memory overhead.
  */
-final class UnmodifiableChildrenMap implements CloneableMap<PathArgument, DataContainerChild<? extends PathArgument, ?>>, Serializable {
+final class UnmodifiableChildrenMap
+        implements CloneableMap<PathArgument, DataContainerChild<? extends PathArgument, ?>>, Serializable {
     private static final long serialVersionUID = 1L;
     /*
      * Do not wrap maps which are smaller than this and instead copy them into
@@ -44,7 +45,8 @@ final class UnmodifiableChildrenMap implements CloneableMap<PathArgument, DataCo
      * @param map Backing map
      * @return Unmodifiable view
      */
-    static Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> create(final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> map) {
+    static Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> create(
+            final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> map) {
         if (map instanceof UnmodifiableChildrenMap) {
             return map;
         }
@@ -98,7 +100,8 @@ final class UnmodifiableChildrenMap implements CloneableMap<PathArgument, DataCo
     }
 
     @Override
-    public void putAll(@Nonnull final Map<? extends PathArgument, ? extends DataContainerChild<? extends PathArgument, ?>> m) {
+    @SuppressWarnings("checkstyle:parameterName")
+    public void putAll(final Map<? extends PathArgument, ? extends DataContainerChild<? extends PathArgument, ?>> m) {
         throw new UnsupportedOperationException();
     }
 
@@ -134,8 +137,8 @@ final class UnmodifiableChildrenMap implements CloneableMap<PathArgument, DataCo
     }
 
     @Override
-    public boolean equals(final Object o) {
-        return this == o || delegate.equals(o);
+    public boolean equals(final Object obj) {
+        return this == obj || delegate.equals(obj);
     }
 
     @Override
@@ -152,7 +155,8 @@ final class UnmodifiableChildrenMap implements CloneableMap<PathArgument, DataCo
     @SuppressWarnings("unchecked")
     public Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> createMutableClone() {
         if (delegate instanceof HashMap) {
-            return (Map<PathArgument, DataContainerChild<? extends PathArgument, ?>>) ((HashMap<?, ?>) delegate).clone();
+            return (Map<PathArgument, DataContainerChild<? extends PathArgument, ?>>)
+                    ((HashMap<?, ?>) delegate).clone();
         }
 
         return new HashMap<>(delegate);
index 58f381582545891e73616c2d748ad4a927021a81..42c37ca3a9c0ea86fccf9636f81d815ed696ff58 100644 (file)
@@ -21,7 +21,8 @@ abstract class AbstractCursorAware {
 
     protected <T extends AbstractCursor<?>> T openCursor(final T cursor) {
         final boolean success = CURSOR_UPDATER.compareAndSet(this, null, cursor);
-        Preconditions.checkState(success, "Modification %s has cursor attached at path %s", this, this.cursor.getRootPath());
+        Preconditions.checkState(success, "Modification %s has cursor attached at path %s", this,
+            this.cursor.getRootPath());
         return cursor;
     }
 
index 53d6d2fae1511e19bb634eacce5dc90c4afed756..ec05117bec1081cb64f25ad49d99a0ce269c6586 100644 (file)
@@ -32,25 +32,29 @@ import org.slf4j.LoggerFactory;
  *
  * @param <T> Type of the container node
  */
-abstract class AbstractDataNodeContainerModificationStrategy<T extends DataNodeContainer> extends AbstractNodeContainerModificationStrategy {
+abstract class AbstractDataNodeContainerModificationStrategy<T extends DataNodeContainer>
+        extends AbstractNodeContainerModificationStrategy {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDataNodeContainerModificationStrategy.class);
     private final LoadingCache<PathArgument, ModificationApplyOperation> childCache = CacheBuilder.newBuilder()
             .build(new CacheLoader<PathArgument, ModificationApplyOperation>() {
                 @Override
                 public ModificationApplyOperation load(@Nonnull final PathArgument key) {
                     if (key instanceof AugmentationIdentifier && schema instanceof AugmentationTarget) {
-                        return SchemaAwareApplyOperation.from(schema, (AugmentationTarget) schema, (AugmentationIdentifier) key, treeConfig);
+                        return SchemaAwareApplyOperation.from(schema, (AugmentationTarget) schema,
+                            (AugmentationIdentifier) key, treeConfig);
                     }
 
                     final DataSchemaNode child = schema.getDataChildByName(key.getNodeType());
-                    Preconditions.checkArgument(child != null, "Schema %s does not have a node for child %s", schema, key.getNodeType());
+                    Preconditions.checkArgument(child != null, "Schema %s does not have a node for child %s", schema,
+                            key.getNodeType());
                     return SchemaAwareApplyOperation.from(child, treeConfig);
                 }
             });
     private final T schema;
     private final DataTreeConfiguration treeConfig;
 
-    protected AbstractDataNodeContainerModificationStrategy(final T schema, final Class<? extends NormalizedNode<?, ?>> nodeClass, final DataTreeConfiguration treeConfig) {
+    protected AbstractDataNodeContainerModificationStrategy(final T schema,
+            final Class<? extends NormalizedNode<?, ?>> nodeClass, final DataTreeConfiguration treeConfig) {
         super(nodeClass, treeConfig);
         this.schema = Preconditions.checkNotNull(schema,"schema");
         this.treeConfig = Preconditions.checkNotNull(treeConfig,"treeConfig");
@@ -65,7 +69,8 @@ abstract class AbstractDataNodeContainerModificationStrategy<T extends DataNodeC
         try {
             return Optional.fromNullable(childCache.get(identifier));
         } catch (ExecutionException | UncheckedExecutionException e) {
-            LOG.trace("Child {} not present in container schema {} children {}", identifier, this, schema.getChildNodes(), e.getCause());
+            LOG.trace("Child {} not present in container schema {} children {}", identifier, this,
+                schema.getChildNodes(), e.getCause());
             return Optional.absent();
         }
     }
index 082dfd4c870c05c9aa630651af781f8689c57182..37afe6595fe38fc057ba9745d8923150b6484f5b 100644 (file)
@@ -28,7 +28,8 @@ abstract class AbstractDataTreeCandidateNode implements DataTreeCandidateNode {
 
     static DataTreeCandidateNode deltaChild(
             final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData,
-            final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> newData, final PathArgument identifier) {
+            final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> newData,
+            final PathArgument identifier) {
 
         final Optional<NormalizedNode<?, ?>> maybeNewChild = getChild(newData, identifier);
         final Optional<NormalizedNode<?, ?>> maybeOldChild = getChild(oldData, identifier);
index 7705059c4ab60c603855f8a021ee5a9ce70646d9..6e7c9be6c182e74f38c8e5a7874d5cc84f0c7da1 100644 (file)
@@ -52,7 +52,8 @@ abstract class AbstractDataTreeTip implements DataTreeTip {
 
         final Optional<TreeNode> newRoot = m.getStrategy().apply(m.getRootModification(),
             Optional.of(currentRoot), m.getVersion());
-        Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node for modification %s", modification);
+        Preconditions.checkState(newRoot.isPresent(), "Apply strategy failed to produce root node for modification %s",
+            modification);
         return new InMemoryDataTreeCandidate(YangInstanceIdentifier.EMPTY, root, currentRoot, newRoot.get());
     }
 }
index 02d961eed3c05d1fb0dd1dfd802623b01dfa4252..80d63ba83f0d07c05c838d07a184cf3ac4c87ef6 100644 (file)
@@ -60,8 +60,9 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     }
 
     @SuppressWarnings("unchecked")
-    private static NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> getContainer(@Nullable final TreeNode meta) {
-        return (meta == null ? null : (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>)meta.getData());
+    private static NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> getContainer(
+            @Nullable final TreeNode meta) {
+        return meta == null ? null : (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>)meta.getData();
     }
 
     private ChildNode childNode(final ModifiedNode childMod) {
@@ -73,29 +74,29 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     @Nonnull
     public Collection<DataTreeCandidateNode> getChildNodes() {
         switch (mod.getModificationType()) {
-        case APPEARED:
-        case DISAPPEARED:
-        case SUBTREE_MODIFIED:
-            return Collections2.transform(mod.getChildren(), this::childNode);
-        case UNMODIFIED:
-            // Unmodified node, but we still need to resolve potential children. canHaveChildren returns
-            // false if both arguments are null.
-            if (!canHaveChildren(oldMeta, newMeta)) {
-                return ImmutableList.of();
-            }
-
-            return Collections2.transform(getContainer(newMeta != null ? newMeta : oldMeta).getValue(),
-                AbstractRecursiveCandidateNode::unmodifiedNode);
-        case DELETE:
-        case WRITE:
-            // This is unusual, the user is requesting we follow into an otherwise-terminal node.
-            // We need to fudge things based on before/after data to correctly fake the expectations.
-            if (!canHaveChildren(oldMeta, newMeta)) {
-                return ImmutableList.of();
-            }
-            return AbstractDataTreeCandidateNode.deltaChildren(getContainer(oldMeta), getContainer(newMeta));
-        default:
-            throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+            case APPEARED:
+            case DISAPPEARED:
+            case SUBTREE_MODIFIED:
+                return Collections2.transform(mod.getChildren(), this::childNode);
+            case UNMODIFIED:
+                // Unmodified node, but we still need to resolve potential children. canHaveChildren returns
+                // false if both arguments are null.
+                if (!canHaveChildren(oldMeta, newMeta)) {
+                    return ImmutableList.of();
+                }
+
+                return Collections2.transform(getContainer(newMeta != null ? newMeta : oldMeta).getValue(),
+                    AbstractRecursiveCandidateNode::unmodifiedNode);
+            case DELETE:
+            case WRITE:
+                // This is unusual, the user is requesting we follow into an otherwise-terminal node.
+                // We need to fudge things based on before/after data to correctly fake the expectations.
+                if (!canHaveChildren(oldMeta, newMeta)) {
+                    return ImmutableList.of();
+                }
+                return AbstractDataTreeCandidateNode.deltaChildren(getContainer(oldMeta), getContainer(newMeta));
+            default:
+                throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
         }
     }
 
@@ -124,29 +125,30 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
     @Override
     public final DataTreeCandidateNode getModifiedChild(final PathArgument identifier) {
         switch (mod.getModificationType()) {
-        case APPEARED:
-        case DISAPPEARED:
-        case SUBTREE_MODIFIED:
-            final Optional<ModifiedNode> childMod = mod.getChild(identifier);
-            if (childMod.isPresent()) {
-                return childNode(childMod.get());
-            }
-            return null;
-        case UNMODIFIED:
-            if (!canHaveChildren(oldMeta, newMeta)) {
+            case APPEARED:
+            case DISAPPEARED:
+            case SUBTREE_MODIFIED:
+                final Optional<ModifiedNode> childMod = mod.getChild(identifier);
+                if (childMod.isPresent()) {
+                    return childNode(childMod.get());
+                }
                 return null;
-            }
-            final Optional<NormalizedNode<?, ?>> maybeChild = getContainer(newMeta != null ? newMeta : oldMeta)
-                    .getChild(identifier);
-            return maybeChild.isPresent() ? AbstractRecursiveCandidateNode.unmodifiedNode(maybeChild.get()) : null;
-        case DELETE:
-        case WRITE:
-            if (!canHaveChildren(oldMeta, newMeta)) {
-                return null;
-            }
-            return AbstractDataTreeCandidateNode.deltaChild(getContainer(oldMeta), getContainer(newMeta), identifier);
-        default:
-            throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+            case UNMODIFIED:
+                if (!canHaveChildren(oldMeta, newMeta)) {
+                    return null;
+                }
+                final Optional<NormalizedNode<?, ?>> maybeChild = getContainer(newMeta != null ? newMeta : oldMeta)
+                        .getChild(identifier);
+                return maybeChild.isPresent() ? AbstractRecursiveCandidateNode.unmodifiedNode(maybeChild.get()) : null;
+            case DELETE:
+            case WRITE:
+                if (!canHaveChildren(oldMeta, newMeta)) {
+                    return null;
+                }
+                return AbstractDataTreeCandidateNode.deltaChild(getContainer(oldMeta), getContainer(newMeta),
+                    identifier);
+            default:
+                throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
         }
     }
 
@@ -164,7 +166,7 @@ abstract class AbstractModifiedNodeBasedCandidateNode implements DataTreeCandida
 
     @Override
     public String toString() {
-        return this.getClass().getSimpleName() + "{mod = " + this.mod + ", oldMeta = " + this.oldMeta + ", newMeta = " +
-                this.newMeta + "}";
+        return this.getClass().getSimpleName() + "{mod = " + this.mod + ", oldMeta = " + this.oldMeta + ", newMeta = "
+                this.newMeta + "}";
     }
 }
index f908483b409a22cb54f0a0476c4b90873322316b..f7c3789ba5e8bd85b4280c63c2c37d4dd0239a24 100644 (file)
@@ -18,10 +18,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.MutableTreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
@@ -37,7 +37,7 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
     protected AbstractNodeContainerModificationStrategy(final Class<? extends NormalizedNode<?, ?>> nodeClass,
             final DataTreeConfiguration treeConfig) {
         this.nodeClass = Preconditions.checkNotNull(nodeClass , "nodeClass");
-        this.verifyChildrenStructure = (treeConfig.getTreeType() == TreeType.CONFIGURATION);
+        this.verifyChildrenStructure = treeConfig.getTreeType() == TreeType.CONFIGURATION;
     }
 
     @SuppressWarnings("rawtypes")
@@ -64,7 +64,7 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
 
     @Override
     protected void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) {
-        final NormalizedNodeContainer container = (NormalizedNodeContainer) value;
+        final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) value;
         for (final Object child : container.getValue()) {
             checkArgument(child instanceof NormalizedNode);
             final NormalizedNode<?, ?> castedChild = (NormalizedNode<?, ?>) child;
@@ -73,8 +73,8 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
                 childOp.get().recursivelyVerifyStructure(castedChild);
             } else {
                 throw new SchemaValidationFailedException(
-                        String.format("Node %s is not a valid child of %s according to the schema.",
-                                castedChild.getIdentifier(), container.getIdentifier()));
+                    String.format("Node %s is not a valid child of %s according to the schema.",
+                        castedChild.getIdentifier(), container.getIdentifier()));
             }
         }
     }
@@ -186,12 +186,12 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
         final Collection<NormalizedNode<?, ?>> children = ((NormalizedNodeContainer)value).getValue();
 
         switch (modification.getOperation()) {
-        case NONE:
-            // Fresh node, just record a MERGE with a value
+            case NONE:
+                // Fresh node, just record a MERGE with a value
                 recursivelyVerifyStructure(value);
-            modification.updateValue(LogicalOperation.MERGE, value);
-            return;
-        case TOUCH:
+                modification.updateValue(LogicalOperation.MERGE, value);
+                return;
+            case TOUCH:
 
                 mergeChildrenIntoModification(modification, children, version);
                 // We record empty merge value, since real children merges
@@ -202,38 +202,39 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
                 // before.
                 modification.updateValue(LogicalOperation.MERGE, createEmptyValue(value));
                 return;
-        case MERGE:
-            // Merging into an existing node. Merge data children modifications (maybe recursively) and mark as MERGE,
-            // invalidating cached snapshot
-            mergeChildrenIntoModification(modification, children, version);
+            case MERGE:
+                // Merging into an existing node. Merge data children modifications (maybe recursively) and mark
+                // as MERGE, invalidating cached snapshot
+                mergeChildrenIntoModification(modification, children, version);
                 modification.updateOperationType(LogicalOperation.MERGE);
-            return;
-        case DELETE:
-            // Delete performs a data dependency check on existence of the node. Performing a merge on DELETE means we
-            // are really performing a write. One thing that ruins that are any child modifications. If there are any,
-            // we will perform a read() to get the current state of affairs, turn this into into a WRITE and then
-            // append any child entries.
-            if (!modification.getChildren().isEmpty()) {
-                // Version does not matter here as we'll throw it out
-                final Optional<TreeNode> current = apply(modification, modification.getOriginal(), Version.initial());
-                if (current.isPresent()) {
-                    modification.updateValue(LogicalOperation.WRITE, current.get().getData());
-                    mergeChildrenIntoModification(modification, children, version);
-                    return;
+                return;
+            case DELETE:
+                // Delete performs a data dependency check on existence of the node. Performing a merge on DELETE means
+                // we are really performing a write. One thing that ruins that are any child modifications. If there
+                // are any, we will perform a read() to get the current state of affairs, turn this into into a WRITE
+                // and then append any child entries.
+                if (!modification.getChildren().isEmpty()) {
+                    // Version does not matter here as we'll throw it out
+                    final Optional<TreeNode> current = apply(modification, modification.getOriginal(),
+                        Version.initial());
+                    if (current.isPresent()) {
+                        modification.updateValue(LogicalOperation.WRITE, current.get().getData());
+                        mergeChildrenIntoModification(modification, children, version);
+                        return;
+                    }
                 }
-            }
 
-            modification.updateValue(LogicalOperation.WRITE, value);
-            return;
-        case WRITE:
-            // We are augmenting a previous write. We'll just walk value's children, get the corresponding ModifiedNode
-            // and run recursively on it
-            mergeChildrenIntoModification(modification, children, version);
-            modification.updateOperationType(LogicalOperation.WRITE);
-            return;
+                modification.updateValue(LogicalOperation.WRITE, value);
+                return;
+            case WRITE:
+                // We are augmenting a previous write. We'll just walk value's children, get the corresponding
+                // ModifiedNode and run recursively on it
+                mergeChildrenIntoModification(modification, children, version);
+                modification.updateOperationType(LogicalOperation.WRITE);
+                return;
+            default:
+                throw new IllegalArgumentException("Unsupported operation " + modification.getOperation());
         }
-
-        throw new IllegalArgumentException("Unsupported operation " + modification.getOperation());
     }
 
     @Override
@@ -278,7 +279,8 @@ abstract class AbstractNodeContainerModificationStrategy extends SchemaAwareAppl
     protected void checkTouchApplicable(final YangInstanceIdentifier path, final NodeModification modification,
             final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
         if (!modification.getOriginal().isPresent() && !current.isPresent()) {
-            throw new ModifiedNodeDoesNotExistException(path, String.format("Node %s does not exist. Cannot apply modification to its children.", path));
+            throw new ModifiedNodeDoesNotExistException(path,
+                String.format("Node %s does not exist. Cannot apply modification to its children.", path));
         }
 
         if (!current.isPresent()) {
index ccb49c8a88eca67ed868f3d99bfc17c9f62764bb..4ded53408fd8b3558695ada4522095ac8a069e58 100644 (file)
@@ -65,6 +65,7 @@ abstract class AbstractReadyIterator {
     }
 
     abstract AbstractReadyIterator getParent();
+
     abstract void removeFromParent();
 
     private static final class NestedReadyIterator extends AbstractReadyIterator {
@@ -103,5 +104,4 @@ abstract class AbstractReadyIterator {
             // No-op, since root node cannot be removed
         }
     }
-
 }
\ No newline at end of file
index a352108024e8957dc676c28f79581ac5222e2c3d..41f17098c7695d17de383e0a69b6c3292c31e3fd 100644 (file)
@@ -18,14 +18,16 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNod
 
 abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateNode {
 
-    protected AbstractRecursiveCandidateNode(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data) {
+    protected AbstractRecursiveCandidateNode(
+            final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data) {
         super(data);
     }
 
     @SuppressWarnings("unchecked")
     static DataTreeCandidateNode deleteNode(final NormalizedNode<?, ?> data) {
         if (data instanceof NormalizedNodeContainer) {
-            return new RecursiveDeleteCandidateNode((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
+            return new RecursiveDeleteCandidateNode(
+                (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
         }
         return new DeleteLeafCandidateNode(data);
     }
@@ -33,7 +35,8 @@ abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateN
     @SuppressWarnings("unchecked")
     static DataTreeCandidateNode replaceNode(final NormalizedNode<?, ?> oldData, final NormalizedNode<?, ?> newData) {
         if (isContainer(oldData)) {
-            return new RecursiveReplaceCandidateNode((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) oldData,
+            return new RecursiveReplaceCandidateNode(
+                (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) oldData,
                 (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) newData);
         }
         return new ReplaceLeafCandidateNode(oldData, newData);
@@ -42,7 +45,8 @@ abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateN
     @SuppressWarnings("unchecked")
     static DataTreeCandidateNode unmodifiedNode(final NormalizedNode<?, ?> data) {
         if (data instanceof NormalizedNodeContainer) {
-            return new RecursiveUnmodifiedCandidateNode((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
+            return new RecursiveUnmodifiedCandidateNode(
+                (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
         }
         return new UnmodifiedLeafCandidateNode(data);
     }
@@ -50,7 +54,8 @@ abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateN
     @SuppressWarnings("unchecked")
     static DataTreeCandidateNode writeNode(final NormalizedNode<?, ?> data) {
         if (data instanceof NormalizedNodeContainer) {
-            return new RecursiveWriteCandidateNode((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
+            return new RecursiveWriteCandidateNode(
+                (NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) data);
         }
         return new WriteLeafCandidateNode(data);
     }
@@ -82,7 +87,8 @@ abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateN
         return createLeaf(childData);
     }
 
-    protected abstract DataTreeCandidateNode createContainer(NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData);
+    abstract DataTreeCandidateNode createContainer(
+            NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData);
 
-    protected abstract DataTreeCandidateNode createLeaf(NormalizedNode<?,?> childData);
+    abstract DataTreeCandidateNode createLeaf(NormalizedNode<?,?> childData);
 }
\ No newline at end of file
index efa049e4c12c52a681303bbfacbfd5eefafb75b8..b725c0b0f408b260ca6765183230748f97bd8e87 100644 (file)
@@ -25,7 +25,8 @@ abstract class AbstractValueNodeModificationStrategy<T extends DataSchemaNode> e
     private final Class<? extends NormalizedNode<?, ?>> nodeClass;
     private final T schema;
 
-    protected AbstractValueNodeModificationStrategy(final T schema, final Class<? extends NormalizedNode<?, ?>> nodeClass) {
+    protected AbstractValueNodeModificationStrategy(final T schema,
+            final Class<? extends NormalizedNode<?, ?>> nodeClass) {
         this.nodeClass = Preconditions.checkNotNull(nodeClass);
         this.schema = schema;
     }
index de3e4eaad3227f5dabef01098efa0368866f8ed4..1e81b5e12dc426a517028ba6a3536ef815cd2e29 100644 (file)
@@ -22,7 +22,8 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
 
 final class AugmentationModificationStrategy extends AbstractDataNodeContainerModificationStrategy<AugmentationSchema> {
-    AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved, final DataTreeConfiguration treeConfig) {
+    AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved,
+            final DataTreeConfiguration treeConfig) {
         super(createAugmentProxy(schema,resolved), AugmentationNode.class, treeConfig);
     }
 
@@ -40,7 +41,8 @@ final class AugmentationModificationStrategy extends AbstractDataNodeContainerMo
                 .withNodeIdentifier(((AugmentationNode) original).getIdentifier()).build();
     }
 
-    private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) {
+    private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema,
+            final DataNodeContainer resolved) {
         final Set<DataSchemaNode> realChildSchemas = new HashSet<>();
         for (final DataSchemaNode augChild : schema.getChildNodes()) {
             realChildSchemas.add(resolved.getDataChildByName(augChild.getQName()));
index 6dab3184519449deb6210b3384cb4b08f8d90477..d9fa1694829af5bc8b475787888ba86bb685e500 100644 (file)
@@ -21,7 +21,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -103,13 +102,15 @@ final class ChoiceModificationStrategy extends AbstractNodeContainerModification
         final Collection<DataContainerChild<?, ?>> children = ((ChoiceNode) normalizedNode).getValue();
         if (!children.isEmpty()) {
             final DataContainerChild<?, ?> firstChild = children.iterator().next();
-            final CaseEnforcer enforcer = caseEnforcers.get(firstChild.getIdentifier());
-            Verify.verifyNotNull(enforcer, "Case enforcer cannot be null. Most probably, child node %s of choice node %s does not belong in current tree type.", firstChild.getIdentifier(), normalizedNode.getIdentifier());
+            final CaseEnforcer enforcer = Verify.verifyNotNull(caseEnforcers.get(firstChild.getIdentifier()),
+                "Case enforcer cannot be null. Most probably, child node %s of choice node %s does not belong "
+                + "in current tree type.", firstChild.getIdentifier(), normalizedNode.getIdentifier());
 
             // Make sure no leaves from other cases are present
             for (final CaseEnforcer other : exclusions.get(enforcer)) {
                 for (final PathArgument id : other.getAllChildIdentifiers()) {
-                    final Optional<NormalizedNode<?, ?>> maybeChild = NormalizedNodes.getDirectChild(normalizedNode, id);
+                    final Optional<NormalizedNode<?, ?>> maybeChild = NormalizedNodes.getDirectChild(normalizedNode,
+                        id);
                     Preconditions.checkArgument(!maybeChild.isPresent(),
                         "Child %s (from case %s) implies non-presence of child %s (from case %s), which is %s",
                         firstChild.getIdentifier(), enforcer, id, other, maybeChild.orNull());
index 4636464600b44cedae8b85f41c834adfaff099b6..5e685c37373b3da25345d4404c7be1577f099a75 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 
index 77624b0915fc7cb024981bd3f4b6a7a522d7cf21..75c9af59b375b11d82a2bd0f5eb74158c9015f8a 100644 (file)
@@ -52,8 +52,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
         }
     }
 
-    InMemoryDataTree(final TreeNode rootNode, final DataTreeConfiguration treeConfig, final SchemaContext schemaContext,
-            final DataSchemaNode rootSchemaNode, final boolean maskMandatory) {
+    InMemoryDataTree(final TreeNode rootNode, final DataTreeConfiguration treeConfig,
+            final SchemaContext schemaContext, final DataSchemaNode rootSchemaNode, final boolean maskMandatory) {
         this.treeConfig = Preconditions.checkNotNull(treeConfig, "treeConfig");
         this.maskMandatory = maskMandatory;
 
@@ -92,7 +92,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
         }
 
         final ModificationApplyOperation rootNode = getOperation(rootSchemaNode);
-        DataTreeState currentState, newState;
+        DataTreeState currentState;
+        DataTreeState newState;
         do {
             currentState = state;
             newState = currentState.withSchemaContext(newSchemaContext, rootNode);
@@ -109,7 +110,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
         if (candidate instanceof NoopDataTreeCandidate) {
             return;
         }
-        Preconditions.checkArgument(candidate instanceof InMemoryDataTreeCandidate, "Invalid candidate class %s", candidate.getClass());
+        Preconditions.checkArgument(candidate instanceof InMemoryDataTreeCandidate, "Invalid candidate class %s",
+            candidate.getClass());
         final InMemoryDataTreeCandidate c = (InMemoryDataTreeCandidate)candidate;
 
         if (LOG.isTraceEnabled()) {
@@ -117,7 +119,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
         }
 
         final TreeNode newRoot = c.getTipRoot();
-        DataTreeState currentState, newState;
+        DataTreeState currentState;
+        DataTreeState newState;
         do {
             currentState = state;
             final TreeNode currentRoot = currentState.getRoot();
@@ -127,7 +130,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
             if (oldRoot != currentRoot) {
                 final String oldStr = simpleToString(oldRoot);
                 final String currentStr = simpleToString(currentRoot);
-                throw new IllegalStateException("Store tree " + currentStr + " and candidate base " + oldStr + " differ.");
+                throw new IllegalStateException("Store tree " + currentStr + " and candidate base " + oldStr
+                    + " differ.");
             }
 
             newState = currentState.withRoot(newRoot);
@@ -135,8 +139,8 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
         } while (!STATE_UPDATER.compareAndSet(this, currentState, newState));
     }
 
-    private static String simpleToString(final Object o) {
-        return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
+    private static String simpleToString(final Object obj) {
+        return obj.getClass().getName() + "@" + Integer.toHexString(obj.hashCode());
     }
 
     @Override
@@ -146,11 +150,11 @@ final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducing
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(this).
-                add("object", super.toString()).
-                add("config", treeConfig).
-                add("state", state).
-                toString();
+        return MoreObjects.toStringHelper(this)
+                .add("object", super.toString())
+                .add("config", treeConfig)
+                .add("state", state)
+                .toString();
     }
 
     @Override
index 7b4f4e9c1a0e820fdfc9bbf47ec8a806e5de77ab..af87f9323acdac66388ff95cc6487e2f78063c04 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
 final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
 
     private static final class RootNode extends AbstractModifiedNodeBasedCandidateNode {
-        public RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
+        RootNode(final ModifiedNode mod, final TreeNode oldMeta, final TreeNode newMeta) {
             super(mod, oldMeta, newMeta);
         }
 
@@ -53,6 +53,7 @@ final class InMemoryDataTreeCandidate extends AbstractDataTreeCandidate {
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(this).add("rootPath", getRootPath()).add("rootNode", getRootNode()).toString();
+        return MoreObjects.toStringHelper(this).add("rootPath", getRootPath())
+                .add("rootNode", getRootNode()).toString();
     }
 }
index 381184e4dd6a87236378992f5859b8c95b10acc8..a44ae5c98c2e22697266bc02b2af378fd3171a21 100644 (file)
@@ -107,6 +107,18 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
             initialSchemaContext, rootSchemaNode, maskMandatory);
     }
 
+    private static DataSchemaNode getRootSchemaNode(final SchemaContext schemaContext,
+            final YangInstanceIdentifier rootPath) {
+        final DataSchemaContextTree contextTree = DataSchemaContextTree.from(schemaContext);
+        final DataSchemaContextNode<?> rootContextNode = contextTree.getChild(rootPath);
+        Preconditions.checkArgument(rootContextNode != null, "Failed to find root %s in schema context", rootPath);
+
+        final DataSchemaNode rootSchemaNode = rootContextNode.getDataSchemaNode();
+        Preconditions.checkArgument(rootSchemaNode instanceof DataNodeContainer,
+            "Root %s resolves to non-container type %s", rootPath, rootSchemaNode);
+        return rootSchemaNode;
+    }
+
     private static NormalizedNode<?, ?> createRoot(final DataNodeContainer schemaNode,
             final YangInstanceIdentifier path) {
         if (path.isEmpty()) {
@@ -132,18 +144,6 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
         }
     }
 
-    private static DataSchemaNode getRootSchemaNode(final SchemaContext schemaContext,
-            final YangInstanceIdentifier rootPath) {
-        final DataSchemaContextTree contextTree = DataSchemaContextTree.from(schemaContext);
-        final DataSchemaContextNode<?> rootContextNode = contextTree.getChild(rootPath);
-        Preconditions.checkArgument(rootContextNode != null, "Failed to find root %s in schema context", rootPath);
-
-        final DataSchemaNode rootSchemaNode = rootContextNode.getDataSchemaNode();
-        Preconditions.checkArgument(rootSchemaNode instanceof DataNodeContainer,
-            "Root %s resolves to non-container type %s", rootPath, rootSchemaNode);
-        return rootSchemaNode;
-    }
-
     private static NormalizedNode<?, ?> createRoot(final YangInstanceIdentifier path) {
         if (path.isEmpty()) {
             return ROOT_CONTAINER;
index 34115e1336d88a53d53c15450d117f7a7bbe869b..02e062add73f39af6cf382f873443fb3b9e6aa4c 100644 (file)
@@ -105,6 +105,7 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         return Optional.absent();
     }
 
+    @SuppressWarnings("checkstyle:illegalCatch")
     private Optional<TreeNode> resolveSnapshot(final YangInstanceIdentifier path, final ModifiedNode modification) {
         final Optional<TreeNode> potentialSnapshot = modification.getSnapshot();
         if (potentialSnapshot != null) {
@@ -148,15 +149,15 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         ModificationApplyOperation operation = strategyTree;
         ModifiedNode modification = rootNode;
 
-        int i = 1;
+        int depth = 1;
         for (final PathArgument pathArg : path.getPathArguments()) {
             final Optional<ModificationApplyOperation> potential = operation.getChild(pathArg);
             if (!potential.isPresent()) {
                 throw new SchemaValidationFailedException(String.format("Child %s is not present in schema tree.",
-                        path.getAncestor(i)));
+                        path.getAncestor(depth)));
             }
             operation = potential.get();
-            ++i;
+            ++depth;
 
             modification = modification.modifyChild(pathArg, operation, version);
         }
@@ -217,28 +218,28 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
 
     private static void applyNode(final DataTreeModificationCursor cursor, final ModifiedNode node) {
         switch (node.getOperation()) {
-        case NONE:
-            break;
-        case DELETE:
-            cursor.delete(node.getIdentifier());
-            break;
-        case MERGE:
-            cursor.merge(node.getIdentifier(), node.getWrittenValue());
-            applyChildren(cursor, node);
-            break;
-        case TOUCH:
-            // TODO: we could improve efficiency of cursor use if we could understand
-            //       nested TOUCH operations. One way of achieving that would be a proxy
-            //       cursor, which would keep track of consecutive enter and exit calls
-            //       and coalesce them.
-            applyChildren(cursor, node);
-            break;
-        case WRITE:
-            cursor.write(node.getIdentifier(), node.getWrittenValue());
-            applyChildren(cursor, node);
-            break;
-        default:
-            throw new IllegalArgumentException("Unhandled node operation " + node.getOperation());
+            case NONE:
+                break;
+            case DELETE:
+                cursor.delete(node.getIdentifier());
+                break;
+            case MERGE:
+                cursor.merge(node.getIdentifier(), node.getWrittenValue());
+                applyChildren(cursor, node);
+                break;
+            case TOUCH:
+                // TODO: we could improve efficiency of cursor use if we could understand
+                //       nested TOUCH operations. One way of achieving that would be a proxy
+                //       cursor, which would keep track of consecutive enter and exit calls
+                //       and coalesce them.
+                applyChildren(cursor, node);
+                break;
+            case WRITE:
+                cursor.write(node.getIdentifier(), node.getWrittenValue());
+                applyChildren(cursor, node);
+                break;
+            default:
+                throw new IllegalArgumentException("Unhandled node operation " + node.getOperation());
         }
     }
 
index 26b484cd43a8d10ece6b04ea36f649c66afc3550..9301ec9a1e57d22850ca236a81f5b688d00fd73d 100644 (file)
@@ -20,10 +20,12 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
 
-final class InMemoryDataTreeModificationCursor extends AbstractCursor<InMemoryDataTreeModification> implements DataTreeModificationCursor {
+final class InMemoryDataTreeModificationCursor extends AbstractCursor<InMemoryDataTreeModification>
+        implements DataTreeModificationCursor {
     private final Deque<OperationWithModification> stack = new ArrayDeque<>();
 
-    InMemoryDataTreeModificationCursor(final InMemoryDataTreeModification parent, final YangInstanceIdentifier rootPath, final OperationWithModification rootOp) {
+    InMemoryDataTreeModificationCursor(final InMemoryDataTreeModification parent, final YangInstanceIdentifier rootPath,
+            final OperationWithModification rootOp) {
         super(parent, rootPath);
         stack.push(rootOp);
     }
@@ -62,6 +64,7 @@ final class InMemoryDataTreeModificationCursor extends AbstractCursor<InMemoryDa
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void enter(@Nonnull final Iterable<PathArgument> path) {
         int depth = 0;
         for (PathArgument child : path) {
index cb0c316bb375341955f80545f65daf98db6614dd..460415a6ce9e82ade69c373582d3dff8915b9a6e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
index 2800a5de402e0c150f822fb0c3891bcd2d4c1834..ed5eaf27c2e8701065c5edd6ca3577d9a12759ac 100644 (file)
@@ -21,7 +21,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 final class InMemoryDataTreeSnapshotCursor extends AbstractCursor<InMemoryDataTreeSnapshot> {
     private final Deque<NormalizedNodeContainer<?, ?, ?>> stack = new ArrayDeque<>();
 
-    InMemoryDataTreeSnapshotCursor(final InMemoryDataTreeSnapshot parent, final YangInstanceIdentifier rootPath, final NormalizedNodeContainer<?, ?, ?> normalizedNode) {
+    InMemoryDataTreeSnapshotCursor(final InMemoryDataTreeSnapshot parent, final YangInstanceIdentifier rootPath,
+            final NormalizedNodeContainer<?, ?, ?> normalizedNode) {
         super(parent, rootPath);
         stack.push(normalizedNode);
     }
@@ -37,6 +38,7 @@ final class InMemoryDataTreeSnapshotCursor extends AbstractCursor<InMemoryDataTr
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void enter(@Nonnull final Iterable<PathArgument> path) {
         final Optional<NormalizedNode<?, ?>> maybeChildNode = NormalizedNodes.findNode(stack.peek(), path);
         Preconditions.checkArgument(maybeChildNode.isPresent(), "Child %s not found", path);
index aed8087641f2cdb63a6fe915a98f4c14ecdf40a3..33fc91a08b160dc443ecfe6dc0de9bc071611e90 100644 (file)
@@ -8,50 +8,45 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 /**
- * Holder and factory for upgradable root modifications
+ * Holder and factory for upgradable root modifications.
  *
- * This class is factory for upgradable root modifications and provides an
- * access to set latest backing implementation.
+ * <p>
+ * This class is factory for upgradable root modifications and provides an access to set latest backing implementation.
  */
 final class LatestOperationHolder {
 
     private ModificationApplyOperation current = AlwaysFailOperation.INSTANCE;
 
     /**
-     * Return latest backing implemenation
+     * Return latest backing implementation.
      *
-     * @return
+     * @return latest backing implementation
      */
     ModificationApplyOperation getCurrent() {
         return current;
     }
 
     /**
-     * Sets latest backing implementation of associated
-     * {@link RootModificationApplyOperation}.
+     * Sets latest backing implementation of associated {@link RootModificationApplyOperation}.
+     *
      * <p>
-     * Note: This does not result in upgrading implementation of already
-     * existing {@link RootModificationApplyOperation}. Users, which
-     * obtained instances using {@link #newSnapshot()}, deriving
-     * {@link RootModificationApplyOperation} from this modification must
-     * explicitly invoke
-     * {@link RootModificationApplyOperation#upgradeIfPossible()} on their
-     * instance to be updated to latest backing implementation.
+     * Note: This does not result in upgrading implementation of already existing
+     * {@link RootModificationApplyOperation}. Users, who obtained instances using {@link #newSnapshot()}, deriving
+     * {@link RootModificationApplyOperation} from this modification must explicitly invoke
+     * {@link RootModificationApplyOperation#upgradeIfPossible()} on their instance to be updated to latest backing
+     * implementation.
      *
-     * @param newApplyOper
-     *            New backing implementation
+     * @param newApplyOper New backing implementation
      */
     void setCurrent(final ModificationApplyOperation newApplyOper) {
         current = newApplyOper;
     }
 
     /**
+     * Creates new upgradable {@link RootModificationApplyOperation} associated with holder.
      *
-     * Creates new upgradable {@link RootModificationApplyOperation}
-     * associated with holder.
-     *
-     * @return New upgradable {@link RootModificationApplyOperation} with
-     *         {@link #getCurrent()} used as backing implementation.
+     * @return New upgradable {@link RootModificationApplyOperation} with {@link #getCurrent()} used
+     *         as the backing implementation.
      */
     RootModificationApplyOperation newSnapshot() {
         return new UpgradableModificationApplyOperation(this, current);
index 07049d99a6e688c060fa110b7a2c5aa89e2540e7..d2d6a893d692689b7174c82939562f34e8ca563a 100644 (file)
@@ -58,7 +58,7 @@ abstract class MandatoryLeafEnforcer implements Immutable {
         enforceOnData(tree.getData());
     }
 
-    abstract void enforceOnData(final NormalizedNode<?, ?> normalizedNode);
+    abstract void enforceOnData(NormalizedNode<?, ?> normalizedNode);
 
     private static void findMandatoryNodes(final Builder<YangInstanceIdentifier> builder,
             final YangInstanceIdentifier id, final DataNodeContainer schema, final TreeType type) {
@@ -72,7 +72,7 @@ abstract class MandatoryLeafEnforcer implements Immutable {
                 } else {
                     final ConstraintDefinition constraints = child.getConstraints();
                     final Integer minElements = constraints.getMinElements();
-                    if (constraints.isMandatory() || (minElements != null && minElements.intValue() > 0)) {
+                    if (constraints.isMandatory() || minElements != null && minElements.intValue() > 0) {
                         final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName()));
                         LOG.debug("Adding mandatory child {}", childId);
                         builder.add(childId.toOptimized());
index a960d284be981d9a962aa4dea018a71487b1b799..59d0d28133222850dbf7a58c9f3e27f14e55837f 100644 (file)
@@ -19,10 +19,12 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 /**
  * Operation responsible for applying {@link ModifiedNode} on tree.
  *
+ * <p>
  * Operation is composite - operation on top level node consists of
  * suboperations on child nodes. This allows to walk operation hierarchy and
  * invoke suboperations independently.
  *
+ * <p>
  * <b>Implementation notes</b>
  * <ul>
  * <li>
@@ -30,16 +32,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  * nodes expose via {@link #getChild(PathArgument)} method.
  * <li>Same suboperations SHOULD be used when invoked via
  * {@link #apply(ModifiedNode, Optional, Version)} if applicable.
+ * </ul>
  *
- *
+ * <p>
  * Hierarchical composite operation which is responsible for applying
  * modification on particular subtree and creating updated subtree
  */
 abstract class ModificationApplyOperation implements StoreTreeNode<ModificationApplyOperation> {
     /**
-     *
-     * Implementation of this operation must be stateless and must not change
-     * state of this object.
+     * Implementation of this operation must be stateless and must not change state of this object.
      *
      * @param modification
      *            NodeModification to be applied
@@ -47,12 +48,12 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
      *            Store Metadata Node on which NodeModification should be
      *            applied
      * @param version New subtree version of parent node
-     * @throws IllegalArgumentException
-     *             If it is not possible to apply Operation on provided Metadata
-     *             node
      * @return new {@link TreeNode} if operation resulted in updating
      *         node, {@link Optional#absent()} if {@link ModifiedNode}
      *         resulted in deletion of this node.
+     * @throws IllegalArgumentException
+     *             If it is not possible to apply Operation on provided Metadata
+     *             node
      */
     abstract Optional<TreeNode> apply(ModifiedNode modification, Optional<TreeNode> storeMeta, Version version);
 
@@ -61,13 +62,13 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
      *
      * @param modification Modification
      * @param current Metadata Node to which modification should be applied
-     * @param version
+     * @param version Metadata version
      * @throws DataValidationFailedException if the modification is not applicable
      */
-   abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification, Optional<TreeNode> current, Version version) throws DataValidationFailedException;
+    abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification,
+            Optional<TreeNode> current, Version version) throws DataValidationFailedException;
 
     /**
-     *
      * Performs structural verification of NodeModification, such as writen values / types uses
      * right structural elements.
      *
@@ -76,8 +77,7 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
      * @throws IllegalArgumentException If provided NodeModification does not adhere to the
      *         structure.
      */
-    abstract void verifyStructure(NormalizedNode<?, ?> modification, boolean verifyChildren)
-            throws IllegalArgumentException;
+    abstract void verifyStructure(NormalizedNode<?, ?> modification, boolean verifyChildren);
 
     /**
      * Return the tracking policy for this node's children.
@@ -98,10 +98,10 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
     abstract void mergeIntoModifiedNode(ModifiedNode modification, NormalizedNode<?, ?> value, Version version);
 
     /**
-     * Returns a suboperation for specified tree node
+     * Returns a suboperation for specified tree node.
      *
      * @return Reference to suboperation for specified tree node, {@link Optional#absent()}
-     *    if suboperation is not supported for specified tree node.
+     *         if suboperation is not supported for specified tree node.
      */
     @Override
     public abstract Optional<ModificationApplyOperation> getChild(PathArgument child);
index 35da5d3650a4c87987b46679acb1625461e5c880..550b52558636525cb3e70aab8a6fa41e3d25330a 100644 (file)
@@ -24,12 +24,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 
 /**
- * Node Modification Node and Tree
+ * Node Modification Node and Tree.
  *
+ * <p>
  * Tree which structurally resembles data tree and captures client modifications to the data store tree. This tree is
  * lazily created and populated via {@link #modifyChild(PathArgument, ModificationApplyOperation, Version)} and
  * {@link TreeNode} which represents original state as tracked by {@link #getOriginal()}.
  *
+ * <p>
  * The contract is that the state information exposed here preserves the temporal ordering of whatever modifications
  * were executed. A child's effects pertain to data node as modified by its ancestors. This means that in order to
  * reconstruct the effective data node presentation, it is sufficient to perform a depth-first pre-order traversal of
@@ -47,9 +49,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
             case TOUCH:
             case NONE:
                 return false;
+            default:
+                throw new IllegalArgumentException("Unhandled modification type " + input.getOperation());
         }
-
-        throw new IllegalArgumentException(String.format("Unhandled modification type %s", input.getOperation()));
     };
 
     private final Map<PathArgument, ModifiedNode> children;
@@ -68,7 +70,8 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     private Optional<TreeNode> validatedCurrent;
     private TreeNode validatedNode;
 
-    private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original, final ChildTrackingPolicy childPolicy) {
+    private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original,
+            final ChildTrackingPolicy childPolicy) {
         this.identifier = identifier;
         this.original = original;
         this.children = childPolicy.createMap();
@@ -102,12 +105,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     }
 
     /**
+     * Returns child modification if child was modified.
      *
-     * Returns child modification if child was modified
-     *
-     * @return Child modification if direct child or it's subtree
-     *  was modified.
-     *
+     * @return Child modification if direct child or it's subtree was modified.
      */
     @Override
     public Optional<ModifiedNode> getChild(final PathArgument child) {
@@ -140,28 +140,25 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
      */
     private Optional<TreeNode> findOriginalMetadata(@Nonnull final PathArgument child, final Version modVersion) {
         switch (operation) {
-        case DELETE:
-            // DELETE implies non-presence
-            return Optional.absent();
-        case NONE:
-        case TOUCH:
-        case MERGE:
-            return metadataFromSnapshot(child);
-        case WRITE:
-            // WRITE implies presence based on written data
-            return metadataFromData(child, modVersion);
+            case DELETE:
+                // DELETE implies non-presence
+                return Optional.absent();
+            case NONE:
+            case TOUCH:
+            case MERGE:
+                return metadataFromSnapshot(child);
+            case WRITE:
+                // WRITE implies presence based on written data
+                return metadataFromData(child, modVersion);
+            default:
+                throw new IllegalStateException("Unhandled node operation " + operation);
         }
-
-        throw new IllegalStateException("Unhandled node operation " + operation);
     }
 
     /**
-     *
      * Returns child modification if child was modified, creates {@link ModifiedNode}
-     * for child otherwise.
-     *
-     * If this node's {@link ModificationType} is {@link ModificationType#UNMODIFIED}
-     * changes modification type to {@link ModificationType#SUBTREE_MODIFIED}
+     * for child otherwise. If this node's {@link ModificationType} is {@link ModificationType#UNMODIFIED}
+     * changes modification type to {@link ModificationType#SUBTREE_MODIFIED}.
      *
      * @param child child identifier, may not be null
      * @param childOper Child operation
@@ -201,7 +198,7 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     }
 
     /**
-     * Returns all recorded direct child modification
+     * Returns all recorded direct child modifications.
      *
      * @return all recorded direct child modifications
      */
@@ -217,31 +214,29 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
         final LogicalOperation newType;
 
         switch (operation) {
-        case DELETE:
-        case NONE:
-            // We need to record this delete.
-            newType = LogicalOperation.DELETE;
-            break;
-        case MERGE:
-                // In case of merge - delete needs to be recored and must not to be changed into
-                // NONE, because lazy expansion of parent MERGE node would reintroduce it
-                // again.
+            case DELETE:
+            case NONE:
+                // We need to record this delete.
                 newType = LogicalOperation.DELETE;
                 break;
-        case TOUCH:
-        case WRITE:
-            /*
-             * We are canceling a previous modification. This is a bit tricky,
-             * as the original write may have just introduced the data, or it
-             * may have modified it.
-             *
-             * As documented in BUG-2470, a delete of data introduced in this
-             * transaction needs to be turned into a no-op.
-             */
-            newType = original.isPresent() ? LogicalOperation.DELETE : LogicalOperation.NONE;
-            break;
-        default:
-            throw new IllegalStateException("Unhandled deletion of node with " + operation);
+            case MERGE:
+                // In case of merge - delete needs to be recored and must not to be changed into NONE, because lazy
+                // expansion of parent MERGE node would reintroduce it again.
+                newType = LogicalOperation.DELETE;
+                break;
+            case TOUCH:
+            case WRITE:
+                /*
+                 * We are canceling a previous modification. This is a bit tricky, as the original write may have just
+                 * introduced the data, or it may have modified it.
+                 *
+                 * As documented in BUG-2470, a delete of data introduced in this transaction needs to be turned into
+                 * a no-op.
+                 */
+                newType = original.isPresent() ? LogicalOperation.DELETE : LogicalOperation.NONE;
+                break;
+            default:
+                throw new IllegalStateException("Unhandled deletion of node with " + operation);
         }
 
         clearSnapshot();
@@ -253,7 +248,7 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     /**
      * Records a write for associated node.
      *
-     * @param value
+     * @param value new value
      */
     void write(final NormalizedNode<?, ?> value) {
         updateValue(LogicalOperation.WRITE, value);
@@ -263,7 +258,8 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     /**
      * Seal the modification node and prune any children which has not been modified.
      *
-     * @param schema
+     * @param schema associated apply operation
+     * @param version target version
      */
     void seal(final ModificationApplyOperation schema, final Version version) {
         clearSnapshot();
index 9d550307829eeaea1dd395de036f49505e71379f..df179d09e910ef84d2d365b36dd3453e79f9f31d 100644 (file)
@@ -63,7 +63,8 @@ final class NoopDataTreeCandidate extends AbstractDataTreeCandidate {
     };
     private final TreeNode afterRoot;
 
-    protected NoopDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot, final TreeNode afterRoot) {
+    protected NoopDataTreeCandidate(final YangInstanceIdentifier rootPath, final ModifiedNode modificationRoot,
+            final TreeNode afterRoot) {
         super(rootPath);
         Preconditions.checkArgument(modificationRoot.getOperation() == LogicalOperation.NONE);
         this.afterRoot = Preconditions.checkNotNull(afterRoot);
index efb4ae2f371c3461c53b15597d866c7a89419279..e72f5240941b7243e329a3f2dd3558688f09cfad 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 final class NotUpgradableModificationApplyOperation extends RootModificationApplyOperation {
     private final ModificationApplyOperation delegate;
 
-    public NotUpgradableModificationApplyOperation(final ModificationApplyOperation delegate) {
+    NotUpgradableModificationApplyOperation(final ModificationApplyOperation delegate) {
         this.delegate = delegate;
     }
 
index 760e306c451db2d4b9bdaf196f13ef71197d74d4..f5e9482f6f5d5276c1372982765ad2d60454d2dd 100644 (file)
@@ -53,10 +53,6 @@ final class OperationWithModification {
     /**
      * Read a particular child. If the child has been modified and does not have a stable
      * view, one will we instantiated with specified version.
-     *
-     * @param child
-     * @param version
-     * @return
      */
     Optional<NormalizedNode<?, ?>> read(final PathArgument child, final Version version) {
         final Optional<ModifiedNode> maybeChild = modification.getChild(child);
index 41278aea2b4ebb2b51022a800c827aac3d6498bc..7faca35ea4da6fe5b0341641d5566bc56c88cfb1 100644 (file)
@@ -22,7 +22,8 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 final class PresenceContainerModificationStrategy extends ContainerModificationStrategy {
     private final MandatoryLeafEnforcer enforcer;
 
-    PresenceContainerModificationStrategy(final ContainerSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
+    PresenceContainerModificationStrategy(final ContainerSchemaNode schemaNode,
+            final DataTreeConfiguration treeConfig) {
         super(schemaNode, treeConfig);
         enforcer = MandatoryLeafEnforcer.forContainer(schemaNode, treeConfig);
     }
index 427e5477184a0fac88b01162585e163b708902e8..4555e7b910d3ea02f8cfd80464339950851dad07 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
@@ -27,7 +27,7 @@ final class RecursiveDeleteCandidateNode extends AbstractRecursiveCandidateNode
     }
 
     @Override
-    protected DataTreeCandidateNode createContainer(
+    DataTreeCandidateNode createContainer(
             final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData) {
         return new RecursiveDeleteCandidateNode(childData);
     }
@@ -45,7 +45,7 @@ final class RecursiveDeleteCandidateNode extends AbstractRecursiveCandidateNode
     }
 
     @Override
-    protected DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
+    DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
         return new DeleteLeafCandidateNode(childData);
     }
 }
\ No newline at end of file
index 26b65dd162bf773e3c71c0107bcdab5da2f74e66..0f44ccf81ef9f673195bfed552269ab0dbbc871f 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 final class RecursiveReplaceCandidateNode extends AbstractDataTreeCandidateNode {
     private final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData;
 
-    public RecursiveReplaceCandidateNode(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData,
+    RecursiveReplaceCandidateNode(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> oldData,
             final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> newData) {
         super(newData);
         this.oldData = Preconditions.checkNotNull(oldData);
index 555286127e9db21f6f3c8495ce40e47bcf7ab9fc..41be09ff2b09d4364b6557a965cae5cf7b8742a5 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
@@ -16,7 +16,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNod
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 
 final class RecursiveUnmodifiedCandidateNode extends AbstractRecursiveCandidateNode {
-    protected RecursiveUnmodifiedCandidateNode(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data) {
+    protected RecursiveUnmodifiedCandidateNode(
+            final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data) {
         super(data);
     }
 
@@ -39,12 +40,13 @@ final class RecursiveUnmodifiedCandidateNode extends AbstractRecursiveCandidateN
     }
 
     @Override
-    protected DataTreeCandidateNode createContainer(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData) {
+    DataTreeCandidateNode createContainer(
+            final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData) {
         return new RecursiveUnmodifiedCandidateNode(childData);
     }
 
     @Override
-    protected DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
+    DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
         return new UnmodifiedLeafCandidateNode(childData);
     }
 }
index cd72cae0b3b3060775146b70e34ed7a717ed8efb..a90190a6ac0234a1b265cfe0696313c260a88cbb 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
@@ -28,13 +28,13 @@ final class RecursiveWriteCandidateNode extends AbstractRecursiveCandidateNode {
     }
 
     @Override
-    protected DataTreeCandidateNode createContainer(
+    DataTreeCandidateNode createContainer(
             final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData) {
         return new RecursiveWriteCandidateNode(childData);
     }
 
     @Override
-    protected DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
+    DataTreeCandidateNode createLeaf(final NormalizedNode<?, ?> childData) {
         return new WriteLeafCandidateNode(childData);
     }
 
index ead1ebff6d3aef49162092dd04712760d427e739..ff84f3c25f83e594d87933a8d6fc41fa18c3811e 100644 (file)
@@ -35,9 +35,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  * <li><b>Not Upgradable</b> - operation is immutable, invocation of
  * {@link #upgradeIfPossible()} is no-op and method {@link #snapshot()} returns
  * pointer on same object.
- *
+ * </ul>
  * <h3>Upgradable Root Modification Operation</h3>
- *
  * Upgradable Root Modification Operation may be created using:
  * <ul>
  * <li> {@link #from(ModificationApplyOperation)} with other upgradable root
@@ -46,18 +45,19 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  * Root Modification Operations and provides an option to set latest
  * implementation.
  * </ul>
+ *
  * <p>
  * Upgradable root operation is never upgraded to latest operation
  * automatically, but client code must explicitly invoke
  * {@link #upgradeIfPossible()} to get latest implementation.
  *
+ * <p>
  * Note: This is helpful for implementing
  * {@link org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification}
  * which may be derived from
  * {@link org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree} before
  * update of schema and user actually writes data after schema update. During
  * update user did not invoked any operation.
- *
  */
 abstract class RootModificationApplyOperation extends ModificationApplyOperation {
 
@@ -100,7 +100,7 @@ abstract class RootModificationApplyOperation extends ModificationApplyOperation
     }
 
     @Override
-    void recursivelyVerifyStructure(NormalizedNode<?, ?> value) {
+    void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) {
         getDelegate().recursivelyVerifyStructure(value);
     }
 
@@ -123,9 +123,10 @@ abstract class RootModificationApplyOperation extends ModificationApplyOperation
 
     /**
      * Creates a snapshot from this modification, which may have separate
-     * upgrade lifecycle and is not affected by upgrades
+     * upgrade lifecycle and is not affected by upgrades.
+     *
      * <p>
-     * Newly created snapshot uses backing implementation of this modi
+     * Newly created snapshot uses backing implementation of this modification.
      *
      * @return Derived {@link RootModificationApplyOperation} with separate
      *         upgrade lifecycle.
@@ -134,6 +135,7 @@ abstract class RootModificationApplyOperation extends ModificationApplyOperation
 
     /**
      * Upgrades backing implementation to latest available, if possible.
+     *
      * <p>
      * Latest implementation of {@link RootModificationApplyOperation} is
      * managed by {@link LatestOperationHolder} which was used to construct this
index ecbb678b4e2baa1189e39ae02bac44de19b0b565..9d4cb604f8eb04bf9505daa8532bf6a5b60da3a8 100644 (file)
@@ -36,17 +36,18 @@ import org.slf4j.LoggerFactory;
 abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     private static final Logger LOG = LoggerFactory.getLogger(SchemaAwareApplyOperation.class);
 
-    public static ModificationApplyOperation from(final DataSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
+    public static ModificationApplyOperation from(final DataSchemaNode schemaNode,
+            final DataTreeConfiguration treeConfig) {
         if (treeConfig.getTreeType() == TreeType.CONFIGURATION) {
-            Preconditions.checkArgument(schemaNode.isConfiguration(), "Supplied %s does not belongs to configuration tree.", schemaNode.getPath());
+            Preconditions.checkArgument(schemaNode.isConfiguration(),
+                "Supplied %s does not belongs to configuration tree.", schemaNode.getPath());
         }
         if (schemaNode instanceof ContainerSchemaNode) {
             final ContainerSchemaNode containerSchema = (ContainerSchemaNode) schemaNode;
             if (containerSchema.isPresenceContainer()) {
                 return new PresenceContainerModificationStrategy(containerSchema, treeConfig);
-            } else {
-                return new StructuralContainerModificationStrategy(containerSchema, treeConfig);
             }
+            return new StructuralContainerModificationStrategy(containerSchema, treeConfig);
         } else if (schemaNode instanceof ListSchemaNode) {
             return fromListSchemaNode((ListSchemaNode) schemaNode, treeConfig);
         } else if (schemaNode instanceof ChoiceSchemaNode) {
@@ -60,7 +61,8 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     }
 
     public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree,
-            final AugmentationTarget augSchemas, final AugmentationIdentifier identifier, final DataTreeConfiguration treeConfig) {
+            final AugmentationTarget augSchemas, final AugmentationIdentifier identifier,
+            final DataTreeConfiguration treeConfig) {
         for (final AugmentationSchema potential : augSchemas.getAvailableAugmentations()) {
             for (final DataSchemaNode child : potential.getChildNodes()) {
                 if (identifier.getPossibleChildNames().contains(child.getQName())) {
@@ -79,7 +81,8 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
         }
     }
 
-    private static SchemaAwareApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
+    private static SchemaAwareApplyOperation fromListSchemaNode(final ListSchemaNode schemaNode,
+            final DataTreeConfiguration treeConfig) {
         final List<QName> keyDefinition = schemaNode.getKeyDefinition();
         final SchemaAwareApplyOperation op;
         if (keyDefinition == null || keyDefinition.isEmpty()) {
@@ -92,7 +95,8 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
         return MinMaxElementsValidation.from(op, schemaNode);
     }
 
-    private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
+    private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode,
+            final DataTreeConfiguration treeConfig) {
         final SchemaAwareApplyOperation op;
         if (schemaNode.isUserOrdered()) {
             op =  new OrderedLeafSetModificationStrategy(schemaNode, treeConfig);
@@ -102,7 +106,8 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
         return MinMaxElementsValidation.from(op, schemaNode);
     }
 
-    protected static void checkNotConflicting(final YangInstanceIdentifier path, final TreeNode original, final TreeNode current) throws ConflictingModificationAppliedException {
+    protected static void checkNotConflicting(final YangInstanceIdentifier path, final TreeNode original,
+            final TreeNode current) throws ConflictingModificationAppliedException {
         checkConflicting(path, original.getVersion().equals(current.getVersion()),
                 "Node was replaced by other transaction.");
         checkConflicting(path, original.getSubtreeVersion().equals(current.getSubtreeVersion()),
@@ -116,24 +121,26 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     }
 
     @Override
-    final void checkApplicable(final YangInstanceIdentifier path,final NodeModification modification, final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
+    final void checkApplicable(final YangInstanceIdentifier path,final NodeModification modification,
+            final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
         switch (modification.getOperation()) {
-        case DELETE:
-            checkDeleteApplicable(modification, current);
-            break;
-        case TOUCH:
-            checkTouchApplicable(path, modification, current, version);
-            break;
-        case WRITE:
-            checkWriteApplicable(path, modification, current, version);
-            break;
-        case MERGE:
-            checkMergeApplicable(path, modification, current, version);
-            break;
-        case NONE:
-            break;
-        default:
-            throw new UnsupportedOperationException("Suplied modification type "+ modification.getOperation()+ " is not supported.");
+            case DELETE:
+                checkDeleteApplicable(modification, current);
+                break;
+            case TOUCH:
+                checkTouchApplicable(path, modification, current, version);
+                break;
+            case WRITE:
+                checkWriteApplicable(path, modification, current, version);
+                break;
+            case MERGE:
+                checkMergeApplicable(path, modification, current, version);
+                break;
+            case NONE:
+                break;
+            default:
+                throw new UnsupportedOperationException(
+                    "Suplied modification type " + modification.getOperation() + " is not supported.");
         }
     }
 
@@ -161,7 +168,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
      * @param path Path from current node in TreeNode
      * @param modification modification to apply
      * @param current current node in TreeNode for modification to apply
-     * @throws DataValidationFailedException
+     * @throws DataValidationFailedException when a data dependency conflict is detected
      */
     protected void checkWriteApplicable(final YangInstanceIdentifier path, final NodeModification modification,
         final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
@@ -169,7 +176,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
         if (original.isPresent() && current.isPresent()) {
             checkNotConflicting(path, original.get(), current.get());
         } else if (original.isPresent()) {
-            throw new ConflictingModificationAppliedException(path,"Node was deleted by other transaction.");
+            throw new ConflictingModificationAppliedException(path, "Node was deleted by other transaction.");
         } else if (current.isPresent()) {
             throw new ConflictingModificationAppliedException(path, "Node was created by other transaction.");
         }
@@ -188,40 +195,42 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     }
 
     @Override
-    final Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> currentMeta, final Version version) {
+    final Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> currentMeta,
+            final Version version) {
         switch (modification.getOperation()) {
-        case DELETE:
-            // Deletion of a non-existing node is a no-op, report it as such
-            modification.resolveModificationType(currentMeta.isPresent() ? ModificationType.DELETE : ModificationType.UNMODIFIED);
-            return modification.setSnapshot(Optional.absent());
-        case TOUCH:
-            Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification %s",
+            case DELETE:
+                // Deletion of a non-existing node is a no-op, report it as such
+                modification.resolveModificationType(currentMeta.isPresent() ? ModificationType.DELETE
+                        : ModificationType.UNMODIFIED);
+                return modification.setSnapshot(Optional.absent());
+            case TOUCH:
+                Preconditions.checkArgument(currentMeta.isPresent(), "Metadata not available for modification %s",
                     modification);
-            return modification.setSnapshot(Optional.of(applyTouch(modification, currentMeta.get(),
+                return modification.setSnapshot(Optional.of(applyTouch(modification, currentMeta.get(),
                     version)));
-        case MERGE:
-            final TreeNode result;
+            case MERGE:
+                final TreeNode result;
 
-            if (!currentMeta.isPresent()) {
-                // This is a slight optimization: a merge on a non-existing node equals to a write. Written data
-                // structure is usually verified when the transaction is sealed. To preserve correctness, we have
-                // to run that validation here.
-                modification.resolveModificationType(ModificationType.WRITE);
-                result = applyWrite(modification, currentMeta, version);
-                verifyStructure(result.getData(), true);
-            } else {
-                result = applyMerge(modification, currentMeta.get(), version);
-            }
+                if (!currentMeta.isPresent()) {
+                    // This is a slight optimization: a merge on a non-existing node equals to a write. Written data
+                    // structure is usually verified when the transaction is sealed. To preserve correctness, we have
+                    // to run that validation here.
+                    modification.resolveModificationType(ModificationType.WRITE);
+                    result = applyWrite(modification, currentMeta, version);
+                    verifyStructure(result.getData(), true);
+                } else {
+                    result = applyMerge(modification, currentMeta.get(), version);
+                }
 
-            return modification.setSnapshot(Optional.of(result));
-        case WRITE:
-            modification.resolveModificationType(ModificationType.WRITE);
-            return modification.setSnapshot(Optional.of(applyWrite(modification, currentMeta, version)));
-        case NONE:
-            modification.resolveModificationType(ModificationType.UNMODIFIED);
-            return currentMeta;
-        default:
-            throw new IllegalArgumentException("Provided modification type is not supported.");
+                return modification.setSnapshot(Optional.of(result));
+            case WRITE:
+                modification.resolveModificationType(ModificationType.WRITE);
+                return modification.setSnapshot(Optional.of(applyWrite(modification, currentMeta, version)));
+            case NONE:
+                modification.resolveModificationType(ModificationType.UNMODIFIED);
+                return currentMeta;
+            default:
+                throw new IllegalArgumentException("Provided modification type is not supported.");
         }
     }
 
@@ -252,7 +261,6 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
     protected abstract TreeNode applyTouch(ModifiedNode modification, TreeNode currentMeta, Version version);
 
     /**
-     *
      * Checks is supplied {@link NodeModification} is applicable for Subtree Modification.
      *
      * @param path Path to current node
@@ -260,7 +268,7 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
      * @param current Current state of data tree
      * @throws ConflictingModificationAppliedException If subtree was changed in conflicting way
      * @throws org.opendaylight.yangtools.yang.data.api.schema.tree.IncorrectDataStructureException If subtree
-     * modification is not applicable (e.g. leaf node).
+     *         modification is not applicable (e.g. leaf node).
      */
     protected abstract void checkTouchApplicable(YangInstanceIdentifier path, NodeModification modification,
             Optional<TreeNode> current, Version version) throws DataValidationFailedException;
index f55270ca1fab351d32b8daecd045dcfe830767f6..a1804d07f1b66d57fbaaa323c74e944c6ea1a1f1 100644 (file)
@@ -10,17 +10,17 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 /**
  * SchemaValidationFailedException is thrown when an attempt is made to modify the data tree and the modification
- * does not match the schema context
+ * does not match the schema context.
  */
 public class SchemaValidationFailedException extends IllegalArgumentException {
 
     private static final long serialVersionUID = 1L;
 
-    public SchemaValidationFailedException(String message){
+    public SchemaValidationFailedException(final String message) {
         super(message);
     }
 
-    public SchemaValidationFailedException(String message, Throwable cause){
+    public SchemaValidationFailedException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
index b5e5c265e4bce25ede41f9cb756e88e3f85aa5c4..c1bc659085a5b4241b6f9f82b5e999036972e007 100644 (file)
@@ -13,9 +13,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
@@ -40,7 +40,8 @@ final class StructuralContainerModificationStrategy extends ModificationApplyOpe
     private static final Version FAKE_VERSION = Version.initial();
     private final ContainerModificationStrategy delegate;
 
-    StructuralContainerModificationStrategy(final ContainerSchemaNode schemaNode, final DataTreeConfiguration treeConfig) {
+    StructuralContainerModificationStrategy(final ContainerSchemaNode schemaNode,
+        final DataTreeConfiguration treeConfig) {
         this.delegate = new ContainerModificationStrategy(schemaNode, treeConfig);
     }
 
@@ -50,7 +51,8 @@ final class StructuralContainerModificationStrategy extends ModificationApplyOpe
     }
 
     @Override
-    Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> storeMeta, final Version version) {
+    Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> storeMeta,
+            final Version version) {
         final Optional<TreeNode> ret;
         if (modification.getOperation() == LogicalOperation.TOUCH && !storeMeta.isPresent()) {
             // Container is not present, let's take care of the 'magically appear' part of our job
@@ -101,7 +103,7 @@ final class StructuralContainerModificationStrategy extends ModificationApplyOpe
     }
 
     @Override
-    void verifyStructure(final NormalizedNode<?, ?> modification, final boolean verifyChildren) throws IllegalArgumentException {
+    void verifyStructure(final NormalizedNode<?, ?> modification, final boolean verifyChildren) {
         delegate.verifyStructure(modification, verifyChildren);
     }
 
@@ -116,7 +118,8 @@ final class StructuralContainerModificationStrategy extends ModificationApplyOpe
     }
 
     @Override
-    void mergeIntoModifiedNode(final ModifiedNode modification, final NormalizedNode<?, ?> value, final Version version) {
+    void mergeIntoModifiedNode(final ModifiedNode modification, final NormalizedNode<?, ?> value,
+            final Version version) {
         delegate.mergeIntoModifiedNode(modification, value, version);
     }
 
index 6916059defcbcc1a34743474062bfe3f6a2815f5..86c481e83088f7fd566ad5d651017ae3b593d3d9 100644 (file)
@@ -13,8 +13,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.IncorrectDataStructureException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.IncorrectDataStructureException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.MutableTreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
index 3f09577d540f65076474351a649eee3a36b4c45e..880d61391203570211942e7c9fbeec48e6ea2d2f 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 
index a9aee20a53b44c04f2421113a4cd4746d7b718a2..8dfe89f54b960fb366471c2b4c013eea5f3bfbb3 100644 (file)
@@ -37,7 +37,8 @@ final class UnorderedMapModificationStrategy extends AbstractNodeContainerModifi
         } else if (original instanceof MapEntryNode) {
             return ImmutableMapEntryNodeBuilder.create((MapEntryNode) original);
         }
-        throw new IllegalArgumentException("MapModification strategy can only handle MapNode or MapEntryNode's, offending node: " + original);
+        throw new IllegalArgumentException("MapModification strategy can only handle MapNode or MapEntryNode's, "
+                + "offending node: " + original);
     }
 
     @Override
@@ -45,9 +46,11 @@ final class UnorderedMapModificationStrategy extends AbstractNodeContainerModifi
         if (original instanceof MapNode) {
             return ImmutableMapNodeBuilder.create().withNodeIdentifier(((MapNode) original).getIdentifier()).build();
         } else if (original instanceof MapEntryNode) {
-            return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(((MapEntryNode) original).getIdentifier()).build();
+            return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(
+                ((MapEntryNode) original).getIdentifier()).build();
         }
-        throw new IllegalArgumentException("MapModification strategy can only handle MapNode or MapEntryNode's, offending node: " + original);
+        throw new IllegalArgumentException("MapModification strategy can only handle MapNode or MapEntryNode's, "
+                + "offending node: " + original);
     }
 
     @Override
index 6762cbbf1aab6239e4fd55e4e95b508fd339db8a..6a930ef95ab926727fd97c59cd3316e7c11e2dd1 100644 (file)
@@ -10,20 +10,22 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 /**
  * Implementation of Upgradable {@link RootModificationApplyOperation}
  *
+ * <p>
  * This implementation is associated with {@link LatestOperationHolder}
  * which holds latest available implementation, which may be used for
  * upgrade.
  *
+ * <p>
  * Upgrading {@link LatestOperationHolder} will not affect any instance,
  * unless client invoked {@link #upgradeIfPossible()} which will result in
  * changing delegate to the latest one.
- *
  */
 final class UpgradableModificationApplyOperation extends RootModificationApplyOperation {
     private final LatestOperationHolder holder;
     private ModificationApplyOperation delegate;
 
-    UpgradableModificationApplyOperation(final LatestOperationHolder holder, final ModificationApplyOperation delegate) {
+    UpgradableModificationApplyOperation(final LatestOperationHolder holder,
+        final ModificationApplyOperation delegate) {
         this.holder = holder;
         this.delegate = delegate;
     }
index 57f2056f943c37a4956564ccc73a6834708a34b5..2187584d4915fc57108b7d82553671355791ed1c 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import javax.annotation.Nonnull;
 import com.google.common.base.Optional;
+import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
 final class WriteLeafCandidateNode extends AbstractWriteCandidate {
index bf92b663f759e1c002dc582416c3d56b673cc4f7..5de6c16456dfda54286928abb7735b30df051f6a 100644 (file)
@@ -12,23 +12,22 @@ import org.custommonkey.xmlunit.DifferenceConstants;
 import org.custommonkey.xmlunit.DifferenceListener;
 
 /**
- * Implementatin of {@link DifferenceListener} ignoring white characters around text elements
- * @author mirehak
+ * Implementatin of {@link DifferenceListener} ignoring white characters around text elements.
  *
+ * @author mirehak
  */
 public class IgnoreWhiteCharsDiffListener implements DifferenceListener {
-    
+
     @Override
     public void skippedComparison(org.w3c.dom.Node control,
             org.w3c.dom.Node test) {
-        // do nothing                
+        // do nothing
     }
 
     @Override
     public int differenceFound(Difference diff) {
-        
+
         if (diff.getId() == DifferenceConstants.TEXT_VALUE.getId()) {
-            
             String control = diff.getControlNodeDetail().getValue();
             if (control != null) {
                 control = control.trim();
index 189a16386be2c5528a373d7a81269074dc6f8ca2..d6af21cfb7841cc44fcd17c27d340206658f6a6e 100644 (file)
@@ -5,20 +5,19 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.data.impl;
 
 /**
- * Provides memory consumption and elapsed time between 2 points 
+ * Provides memory consumption and elapsed time between 2 points.
+ *
  * @author mirehak
  */
 public class MemoryConsumption {
-    
     private long memBegin;
     private long tsBegin;
 
     /**
-     * record memory and timestamp
+     * Record memory and timestamp.
      */
     public void startObserving() {
         Runtime runtime = Runtime.getRuntime();
@@ -27,19 +26,21 @@ public class MemoryConsumption {
         memBegin = getActualMemoryConsumption();
         tsBegin = System.currentTimeMillis();
     }
-    
-    
+
     /**
+     * Return memory usage and elapsed time message.
+     *
      * @return memory usage and time elapsed message
      */
     public String finishObserving() {
         long memEnd = getActualMemoryConsumption();
         long tsEnd = System.currentTimeMillis();
-        return String.format("Used memory: %10d B; Elapsed time: %5d ms", (memEnd - memBegin), (tsEnd - tsBegin));
+        return String.format("Used memory: %10d B; Elapsed time: %5d ms", memEnd - memBegin, tsEnd - tsBegin);
     }
-    
-    
+
     /**
+     * Return used memory.
+     *
      * @return actual memory usage
      */
     public static long getActualMemoryConsumption() {
@@ -48,6 +49,4 @@ public class MemoryConsumption {
         long memory = runtime.totalMemory() - runtime.freeMemory();
         return memory;
     }
-    
-    
 }
index f6424413160d548419673a122be8e8123b822f80..2695196159da031b0227f6cd0d744c84accd2d62 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import com.google.common.io.BaseEncoding;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.BinaryCodec;
@@ -29,8 +30,8 @@ public class BinaryCodecStringTest {
         BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
 
         assertEquals("serialize", BaseEncoding.base64().encode(new byte[] { 1, 2, 3, 4 }),
-                      codec.serialize( new byte[] { 1, 2, 3, 4 }));
-        assertEquals( "serialize", "", codec.serialize(null));
+                      codec.serialize(new byte[] { 1, 2, 3, 4 }));
+        assertEquals("serialize", "", codec.serialize(null));
     }
 
     @SuppressWarnings("unchecked")
@@ -39,7 +40,7 @@ public class BinaryCodecStringTest {
         BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
 
         assertArrayEquals("deserialize", new byte[] {1, 2, 3, 4 },
-                      codec.deserialize(BaseEncoding.base64().encode( new byte[] { 1, 2, 3, 4 })));
+                      codec.deserialize(BaseEncoding.base64().encode(new byte[] { 1, 2, 3, 4 })));
         assertEquals("deserialize", null, codec.deserialize(null));
     }
 }
index 25a4e3dd567a58f95cec8682f174da8d56969c11..b29bb690ef855c470632680961f578928d5cb445 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
 import org.junit.Test;
@@ -33,13 +34,13 @@ public class BitsCodecStringTest {
     private  static BitsTypeDefinition toBitsTypeDefinition(final String... bits) {
         final BitsTypeBuilder b = BaseTypes.bitsTypeBuilder(mock(SchemaPath.class));
 
-        long i = 0;
+        long pos = 0;
         for (String bit : bits) {
             BitsTypeDefinition.Bit mockBit = mock(BitsTypeDefinition.Bit.class);
             when(mockBit.getName()).thenReturn(bit);
-            when(mockBit.getPosition()).thenReturn(i);
+            when(mockBit.getPosition()).thenReturn(pos);
             b.addBit(mockBit);
-            ++i;
+            ++pos;
         }
 
         return b.build();
@@ -49,8 +50,8 @@ public class BitsCodecStringTest {
     @Test
     public void testSerialize() {
 
-        BitsCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(
-            toBitsTypeDefinition("foo"), BitsCodec.class);
+        BitsCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(toBitsTypeDefinition("foo"),
+                BitsCodec.class);
 
         ImmutableSet<String> toSerialize = ImmutableSet.of("foo", "bar");
 
index 0db3d173caba071de09685589197d2db8768ccf4..55e95b186b0b40c22ea9890a627ba5bf577d31ef 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
+
 import java.math.BigDecimal;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.DecimalCodec;
@@ -34,7 +35,7 @@ public class DecimalCodecStringTest {
         DecimalCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(getType(), DecimalCodec.class);
 
         assertEquals("serialize", "123.456", codec.serialize(new BigDecimal("123.456")));
-        assertEquals("serialize", "", codec.serialize( null));
+        assertEquals("serialize", "", codec.serialize(null));
     }
 
     @SuppressWarnings("unchecked")
index 9e7bf2619100501149ad7b76f7a302c492ffb867..fc41d6d8c0222cfe44ffef4ae0a82e6d245d9024 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.EmptyCodec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
index 638f87845bba34e78091279d7f2f6996266a102a..513e4745359b819fad751d8631fc1750f33f47f2 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.toEnumTypeDefinition;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.EnumCodec;
 
@@ -34,7 +35,7 @@ public class EnumCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testDeserialize() {
-        EnumCodec<String> codec = getCodec( toEnumTypeDefinition( "enum1", "enum2" ), EnumCodec.class);
+        EnumCodec<String> codec = getCodec(toEnumTypeDefinition("enum1", "enum2"), EnumCodec.class);
 
         assertEquals("deserialize", "enum1", codec.deserialize("enum1"));
         assertEquals("deserialize", "enum2", codec.deserialize("enum2"));
index c0269d6f40695b9492c29a152cea62e3b8852a5b..51ac1a72260962ae256f96ee911c978b8935128d 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int16Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
index 9033cd29d811cc93bdd70a6283604686223ff98a..029de9e336f013a018186bb0d019f7172b347225 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int32Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -25,7 +26,7 @@ public class Int32CodecStringTest {
     public void testSerialize() {
         Int32Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int32Type(), Int32Codec.class);
 
-        assertEquals("serialize", "10", codec.serialize(Integer.valueOf( 10 )));
+        assertEquals("serialize", "10", codec.serialize(Integer.valueOf(10)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
index 72b6e255c5029b38895f8fec98f87d982a8c0236..35617e3112dd29afb1f7aa043f4b59a12633550e 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int64Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -27,7 +28,7 @@ public class Int64CodecStringTest {
     public void testSerialize() {
         Int64Codec<String> codec = getCodec(BaseTypes.int64Type(), Int64Codec.class);
 
-        assertEquals("serialize", "12345", codec.serialize(Long.valueOf( 12345 )));
+        assertEquals("serialize", "12345", codec.serialize(Long.valueOf(12345)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
index 5f5eab430796ee3fdad5c4642426762deac0ef8d..279c98ede3befd7ceb3b367032a1ead37ffd59c9 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Int8Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -25,7 +26,7 @@ public class Int8CodecStringTest {
     public void testSerialize() {
         Int8Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.int8Type(), Int8Codec.class);
 
-        assertEquals("serialize", "10", codec.serialize(Byte.valueOf( (byte) 10 )));
+        assertEquals("serialize", "10", codec.serialize(Byte.valueOf((byte) 10)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
index 370b8741c8deefa231473fb77d0a794070892850..a78c05dd9453ca15320085d85e900844c3690ce4 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.StringCodec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -23,7 +24,8 @@ public class StringCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testSerialize() {
-        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(), StringCodec.class);
+        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
+            StringCodec.class);
 
         assertEquals("serialize", "foo", codec.serialize("foo"));
         assertEquals("serialize", "", codec.serialize(""));
@@ -33,7 +35,8 @@ public class StringCodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testDeserialize() {
-        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(), StringCodec.class);
+        StringCodec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.stringType(),
+            StringCodec.class);
 
         assertEquals("deserialize", "bar", codec.deserialize("bar"));
         assertEquals("deserialize", "", codec.deserialize(""));
index 322de0e655a055e339900cfffb22ac9a288ce7d2..573665c17f5608292f3feb6e19c3b742c26d71c8 100644 (file)
@@ -39,7 +39,8 @@ public class StringPatternCheckingCodecTest {
     @Test
     public void testStringPatternCheckingCodec() throws ReactorException, ParseException, URISyntaxException,
             FileNotFoundException {
-        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/string-pattern-checking-codec-test.yang");
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
+            "/string-pattern-checking-codec-test.yang");
         assertNotNull(schemaContext);
 
         final QNameModule testModuleQName = QNameModule.create(new URI("string-pattern-checking-codec-test"),
@@ -66,7 +67,8 @@ public class StringPatternCheckingCodecTest {
             fail("Exception should have been thrown.");
         } catch (final IllegalArgumentException ex) {
             LOG.debug("IllegalArgumentException was thrown as expected: {}", ex);
-            assertTrue(ex.getMessage().contains("Supplied value does not match the regular expression ^[A-Z]+$. [abcd]"));
+            assertTrue(ex.getMessage().contains(
+                "Supplied value does not match the regular expression ^[A-Z]+$. [abcd]"));
         }
     }
 }
index 5b33d8336ecdc506f38cb30766faad3a3c5fc7e3..222f9ef0298bf1032e98653418e2735ec09d3d2d 100644 (file)
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+
 import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -24,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.util.type.EnumerationTypeBuilder;
 public class TypeDefinitionAwareCodecTestHelper {
 
     @SuppressWarnings("unchecked")
-    public static <T> T getCodec( final TypeDefinition<?> def, final Class<T> clazz) {
+    public static <T> T getCodec(final TypeDefinition<?> def, final Class<T> clazz) {
         Object codec = TypeDefinitionAwareCodec.from(def);
         assertNotNull(codec);
         assertTrue(clazz.isAssignableFrom(codec.getClass()));
@@ -42,13 +43,13 @@ public class TypeDefinitionAwareCodecTestHelper {
 
     public static EnumTypeDefinition toEnumTypeDefinition(final String... enums) {
         final EnumerationTypeBuilder b = BaseTypes.enumerationTypeBuilder(mock(SchemaPath.class));
-        int i = 0;
+        int val = 0;
         for (String en : enums) {
             EnumTypeDefinition.EnumPair mockEnum = mock(EnumTypeDefinition.EnumPair.class);
             when(mockEnum.getName()).thenReturn(en);
-            when(mockEnum.getValue()).thenReturn(i);
+            when(mockEnum.getValue()).thenReturn(val);
             b.addEnum(mockEnum);
-            i++;
+            val++;
         }
 
         return b.build();
index e74ca2596230d7a68e23a5de0bff3869df497c1a..62276189edca436af4bc2bb6a1e7d75d621bbfaf 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint16Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
index 55ae29da1d3a3ebea3e506a6daae75beb01e50fa..d2cec5cfef47d4432a80c30ba9435d403091a138 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint32Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -27,7 +28,7 @@ public class Uint32CodecStringTest {
     public void testSerialize() {
         Uint32Codec<String> codec = getCodec(BaseTypes.uint32Type(), Uint32Codec.class);
 
-        assertEquals("serialize", "10", codec.serialize(Long.valueOf( 10 )));
+        assertEquals("serialize", "10", codec.serialize(Long.valueOf(10)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
index 723bec2740bfbb6f26071093ac4b17a7ee70fdec..4fdaec0eb65c90bb51e853c81719adcdc19ee12e 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
+
 import java.math.BigInteger;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint64Codec;
@@ -24,9 +25,10 @@ public class Uint64CodecStringTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testSerialize() {
-        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(), Uint64Codec.class);
+        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
+            Uint64Codec.class);
 
-        assertEquals("serialize", "123456789", codec.serialize(BigInteger.valueOf( 123456789 )));
+        assertEquals("serialize", "123456789", codec.serialize(BigInteger.valueOf(123456789)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
@@ -37,7 +39,8 @@ public class Uint64CodecStringTest {
         final String octal = "03536670743556272";
         final String integer = "129664115727546";
 
-        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(), Uint64Codec.class);
+        Uint64Codec<String> codec = TypeDefinitionAwareCodecTestHelper.getCodec(BaseTypes.uint64Type(),
+            Uint64Codec.class);
 
         assertEquals("deserialize", codec.deserialize(hexa), new BigInteger("75EDC78edCBA", 16));
         assertEquals("deserialize", codec.deserialize(octal), new BigInteger(octal, 8));
index 9d5d72897e1fa1b67c1aa408cf97642556aa255a..f31944a4959d0dcaf5a56b3630320427b2268338 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.yangtools.yang.data.impl.codecs;
 import static org.junit.Assert.assertEquals;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.Uint8Codec;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
@@ -27,7 +28,7 @@ public class Uint8CodecStringTest {
     public void testSerialize() {
         Uint8Codec<String> codec = getCodec(BaseTypes.uint8Type(), Uint8Codec.class);
 
-        assertEquals("serialize", "10", codec.serialize(Short.valueOf((short) 10 )));
+        assertEquals("serialize", "10", codec.serialize(Short.valueOf((short) 10)));
         assertEquals("serialize", "", codec.serialize(null));
     }
 
index e210b6acb63e1ee3638a6098803d4a778414e59d..2ec4f164640129439b719ca9a297a29166174465 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
@@ -13,6 +12,7 @@ import static org.mockito.Mockito.mock;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.toEnumTypeDefinition;
+
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.codec.UnionCodec;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
index d2663b1de98900bba94e0099db25a0311299951c..7967816bbc1cc28c8f3b25607bb2debf83a963d7 100644 (file)
@@ -32,9 +32,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -170,7 +170,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static void initDataTree() {
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         inMemoryDataTree.setSchemaContext(context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree
@@ -188,7 +188,6 @@ public class DataTreeCandidateValidatorTest {
         final DataTreeCandidate writeContributorsCandidate = inMemoryDataTree
                 .prepare(initialDataTreeModification);
         inMemoryDataTree.commit(writeContributorsCandidate);
-
     }
 
     @Test
@@ -497,12 +496,12 @@ public class DataTreeCandidateValidatorTest {
         return containerBuilder.build();
     }
 
-    private static MapEntryNode createList3Entry(final String kVal,
+    private static MapEntryNode createList3Entry(final String keyVal,
             final String l3Val1, final String l3Val2, final String l3Val3) {
         final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders
                 .mapEntryBuilder();
         mapEntryBuilder.withNodeIdentifier(new NodeIdentifierWithPredicates(
-                list3InChoice, k, kVal));
+                list3InChoice, k, keyVal));
 
         final ListNodeBuilder<Object, LeafSetEntryNode<Object>> leafSetBuilder = Builders
                 .leafSetBuilder();
@@ -512,7 +511,7 @@ public class DataTreeCandidateValidatorTest {
         leafSetBuilder.addChild(createLeafSetEntry(l3, l3Val2));
         leafSetBuilder.addChild(createLeafSetEntry(l3, l3Val3));
 
-        mapEntryBuilder.addChild(ImmutableNodes.leafNode(k, kVal));
+        mapEntryBuilder.addChild(ImmutableNodes.leafNode(k, keyVal));
         mapEntryBuilder.addChild(leafSetBuilder.build());
 
         return mapEntryBuilder.build();
@@ -697,18 +696,12 @@ public class DataTreeCandidateValidatorTest {
         final LeafNode<String> odlProjectDescLeafRef = ImmutableNodes.leafNode(
                 odlProjectDesc, odlProjectDescVal);
 
-        final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> contributorMapEntryBldr = Builders
-                .mapEntryBuilder(contributorListSchemaNode);
-
-        contributorMapEntryBldr.addChild(loginLeaf);
-        contributorMapEntryBldr.addChild(contributorNameLeaf);
-        contributorMapEntryBldr.addChild(odlProjectNameLeafRef);
-        contributorMapEntryBldr.addChild(odlProjectDescLeafRef);
-
-        final MapEntryNode contributorMapEntry = contributorMapEntryBldr
+        return Builders.mapEntryBuilder(contributorListSchemaNode)
+                .addChild(loginLeaf)
+                .addChild(contributorNameLeaf)
+                .addChild(odlProjectNameLeafRef)
+                .addChild(odlProjectDescLeafRef)
                 .build();
-
-        return contributorMapEntry;
     }
 
     private static ContainerNode createOdlContainer(
index a81594812dd431ac49afd50e567858a0f533f873..72e5d89d813dbdbf1279d150458e02c86e218283 100644 (file)
@@ -26,9 +26,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -110,7 +110,7 @@ public class DataTreeCandidateValidatorTest2 {
         LOG.debug("*************************");
         LOG.debug("Before writeDevices: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
 
         boolean exception = false;
         try {
@@ -129,7 +129,7 @@ public class DataTreeCandidateValidatorTest2 {
         LOG.debug("*************************");
         LOG.debug("After write: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
     }
 
     private static void initQnames() {
@@ -167,7 +167,7 @@ public class DataTreeCandidateValidatorTest2 {
 
     private static void initDataTree() {
 
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         inMemoryDataTree.setSchemaContext(context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
@@ -188,7 +188,7 @@ public class DataTreeCandidateValidatorTest2 {
 
         inMemoryDataTree.commit(writeChipsCandidate);
 
-        System.out.println(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
     }
 
     private static void initLeafRefContext() {
index 736b889395553e1a78cde6ade1ae33534c2c39f1..a7bb5162ea9332f6b3fc9deb2e80118a9fd7ae86 100644 (file)
@@ -24,9 +24,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -111,7 +111,7 @@ public class DataTreeCandidateValidatorTest3 {
         LOG.debug("*************************");
         LOG.debug("Before writeDevices: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
 
         boolean exception = false;
         try {
@@ -129,7 +129,7 @@ public class DataTreeCandidateValidatorTest3 {
         LOG.debug("*************************");
         LOG.debug("After writeDevices: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
     }
 
     private static void mergeDevices() {
@@ -149,7 +149,7 @@ public class DataTreeCandidateValidatorTest3 {
         LOG.debug("*************************");
         LOG.debug("Before mergeDevices: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
 
         boolean exception = false;
         try {
@@ -166,7 +166,7 @@ public class DataTreeCandidateValidatorTest3 {
         LOG.debug("*************************");
         LOG.debug("After mergeDevices: ");
         LOG.debug("*************************");
-        LOG.debug(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
 
         assertTrue(exception);
     }
@@ -210,7 +210,7 @@ public class DataTreeCandidateValidatorTest3 {
 
     private static void initDataTree() {
 
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         inMemoryDataTree.setSchemaContext(context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
@@ -231,7 +231,7 @@ public class DataTreeCandidateValidatorTest3 {
 
         inMemoryDataTree.commit(writeChipsCandidate);
 
-        System.out.println(inMemoryDataTree.toString());
+        LOG.debug("{}", inMemoryDataTree);
     }
 
     private static void initLeafRefContext() {
index 7252e3b01b1f51f30f6bc0ab74e359f684798eda..35ce67f88f28fda90deb86e05544bb0863a5c787 100644 (file)
@@ -27,8 +27,11 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class LeafRefContextTreeBuilderTest {
+    private static final Logger LOG = LoggerFactory.getLogger(LeafRefContextTreeBuilderTest.class);
 
     private static SchemaContext context;
     private static Module impMod;
@@ -73,14 +76,10 @@ public class LeafRefContextTreeBuilderTest {
         assertNotNull(leafRefCtx.getAbsoluteLeafRefTargetPath());
         assertTrue(leafRefCtx.getAbsoluteLeafRefTargetPath().isAbsolute());
 
-        System.out.println();
-        System.out.println("******* Test 1 ************");
-        System.out.println("Original definition string:");
-        System.out.println(leafRefCtx.getLeafRefTargetPathString());
-        System.out.println("Parsed leafref path:");
-        System.out.println(leafRefCtx.getLeafRefTargetPath().toString());
-        System.out.println("Absolute leafref path:");
-        System.out.println(leafRefCtx.getAbsoluteLeafRefTargetPath().toString());
+        LOG.debug("******* Test 1 ************");
+        LOG.debug("Original definition string: {}", leafRefCtx.getLeafRefTargetPathString());
+        LOG.debug("Parsed leafref path: {}", leafRefCtx.getLeafRefTargetPath());
+        LOG.debug("Absolute leafref path: {}", leafRefCtx.getAbsoluteLeafRefTargetPath());
     }
 
     @Test
@@ -99,16 +98,10 @@ public class LeafRefContextTreeBuilderTest {
         assertNotNull(leafRefCtx2.getAbsoluteLeafRefTargetPath());
         assertTrue(leafRefCtx2.getAbsoluteLeafRefTargetPath().isAbsolute());
 
-        System.out.println();
-        System.out.println("******* Test 2 ************");
-        System.out.println("Original definition string2:");
-        System.out.println(leafRefCtx2.getLeafRefTargetPathString());
-        System.out.println("Parsed leafref path2:");
-        System.out.println(leafRefCtx2.getLeafRefTargetPath().toString());
-        System.out.println("Absolute leafref path2:");
-        System.out.println(leafRefCtx2.getAbsoluteLeafRefTargetPath().toString());
-        System.out.println();
-
+        LOG.debug("******* Test 2 ************");
+        LOG.debug("Original definition string2: {}", leafRefCtx2.getLeafRefTargetPathString());
+        LOG.debug("Parsed leafref path2: {}", leafRefCtx2.getLeafRefTargetPath());
+        LOG.debug("Absolute leafref path2: {}", leafRefCtx2.getAbsoluteLeafRefTargetPath());
     }
 
     @Test
@@ -129,15 +122,10 @@ public class LeafRefContextTreeBuilderTest {
         assertNotNull(leafRefCtx3.getAbsoluteLeafRefTargetPath());
         assertTrue(leafRefCtx3.getAbsoluteLeafRefTargetPath().isAbsolute());
 
-        System.out.println();
-        System.out.println("******* Test 3 ************");
-        System.out.println("Original definition string2:");
-        System.out.println(leafRefCtx3.getLeafRefTargetPathString());
-        System.out.println("Parsed leafref path2:");
-        System.out.println(leafRefCtx3.getLeafRefTargetPath().toString());
-        System.out.println("Absolute leafref path2:");
-        System.out.println(leafRefCtx3.getAbsoluteLeafRefTargetPath().toString());
-        System.out.println();
+        LOG.debug("******* Test 3 ************");
+        LOG.debug("Original definition string2: {}", leafRefCtx3.getLeafRefTargetPathString());
+        LOG.debug("Parsed leafref path2: {}", leafRefCtx3.getLeafRefTargetPath());
+        LOG.debug("Absolute leafref path2: {}", leafRefCtx3.getAbsoluteLeafRefTargetPath());
     }
 
     @Test
@@ -226,7 +214,6 @@ public class LeafRefContextTreeBuilderTest {
 
         assertNotNull(allChildsReferencedByLeafRef);
         assertTrue(allChildsReferencedByLeafRef.isEmpty());
-
     }
 
     @Test(expected = IllegalArgumentException.class)
@@ -236,5 +223,4 @@ public class LeafRefContextTreeBuilderTest {
             "/leafref-context-test/incorrect-modules");
         LeafRefContext.create(context);
     }
-
 }
index 864ecd8d857e4d7feba4049740ce60e9e444229a..f12cab35a4605c8f324520e44efff450e59da98b 100644 (file)
@@ -22,7 +22,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.util.UnmodifiableCollection;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -67,19 +68,20 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEf
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class BuilderTest {
-    private static final QName ROOT_CONTAINER = QName.create("test.namespace.builder.test", "2016-01-01", "root-container");
+    private static final QName ROOT_CONTAINER = QName.create("test.namespace.builder.test", "2016-01-01",
+        "root-container");
     private static final QName LIST_MAIN = QName.create(ROOT_CONTAINER, "list-ordered-by-user-with-key");
     private static final QName LEAF_LIST_MAIN = QName.create(ROOT_CONTAINER, "leaf-list-ordered-by-user");
     private static final QName LIST_MAIN_CHILD_QNAME_1 = QName.create(ROOT_CONTAINER, "leaf-a");
-    private static final YangInstanceIdentifier.NodeIdentifier NODE_IDENTIFIER_LIST = YangInstanceIdentifier.NodeIdentifier
-            .create(LIST_MAIN);
-    private static final YangInstanceIdentifier.NodeIdentifier NODE_IDENTIFIER_LEAF_LIST = YangInstanceIdentifier.NodeIdentifier
-            .create(LEAF_LIST_MAIN);
-    private static final YangInstanceIdentifier.NodeIdentifier NODE_IDENTIFIER_LEAF = YangInstanceIdentifier
-            .NodeIdentifier.create(LIST_MAIN_CHILD_QNAME_1);
-    private static final MapEntryNode LIST_MAIN_CHILD_1 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 1);
-    private static final MapEntryNode LIST_MAIN_CHILD_2 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 2);
-    private static final MapEntryNode LIST_MAIN_CHILD_3 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1, 3);
+    private static final NodeIdentifier NODE_IDENTIFIER_LIST = NodeIdentifier.create(LIST_MAIN);
+    private static final NodeIdentifier NODE_IDENTIFIER_LEAF_LIST = NodeIdentifier.create(LEAF_LIST_MAIN);
+    private static final NodeIdentifier NODE_IDENTIFIER_LEAF = NodeIdentifier.create(LIST_MAIN_CHILD_QNAME_1);
+    private static final MapEntryNode LIST_MAIN_CHILD_1 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1,
+            1);
+    private static final MapEntryNode LIST_MAIN_CHILD_2 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1,
+            2);
+    private static final MapEntryNode LIST_MAIN_CHILD_3 = ImmutableNodes.mapEntry(LIST_MAIN, LIST_MAIN_CHILD_QNAME_1,
+            3);
     private static final int SIZE = 3;
     private static final NodeWithValue<String> BAR_PATH = new NodeWithValue<>(LEAF_LIST_MAIN, "bar");
     private static final LeafSetEntryNode LEAF_SET_ENTRY_NODE = ImmutableLeafSetEntryNodeBuilder.create()
@@ -106,8 +108,7 @@ public class BuilderTest {
         mapEntryNodeColl.add(LIST_MAIN_CHILD_3);
         final Map<QName, Object> keys = new HashMap<>();
         keys.put(LIST_MAIN_CHILD_QNAME_1, 1);
-        final YangInstanceIdentifier.NodeIdentifierWithPredicates mapEntryPath = new YangInstanceIdentifier
-                .NodeIdentifierWithPredicates(LIST_MAIN, keys);
+        final NodeIdentifierWithPredicates mapEntryPath = new NodeIdentifierWithPredicates(LIST_MAIN, keys);
         final OrderedMapNode orderedMapNodeCreateNull = ImmutableOrderedMapNodeBuilder.create()
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .withChild(LIST_MAIN_CHILD_1)
@@ -123,8 +124,8 @@ public class BuilderTest {
         final OrderedMapNode orderedMapNodeSchemaAware = ImmutableOrderedMapNodeSchemaAwareBuilder.create(list)
                 .withChild(LIST_MAIN_CHILD_1)
                 .build();
-        final OrderedMapNode orderedMapNodeSchemaAwareMapNodeConst = ImmutableOrderedMapNodeSchemaAwareBuilder.create
-                (list, getImmutableOrderedMapNode())
+        final OrderedMapNode orderedMapNodeSchemaAwareMapNodeConst = ImmutableOrderedMapNodeSchemaAwareBuilder.create(
+                list, getImmutableOrderedMapNode())
                 .build();
 
         assertNotNull(Builders.orderedMapBuilder(list));
@@ -147,14 +148,12 @@ public class BuilderTest {
         final LinkedList<LeafSetNode<?>> mapEntryNodeColl = new LinkedList<>();
         mapEntryNodeColl.add((LeafSetNode<?>)orderedLeafSet);
         final UnmodifiableCollection<?> leafSetCollection = (UnmodifiableCollection<?>)orderedLeafSet.getValue();
-        final NormalizedNode<?, ?> orderedMapNodeSchemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList)
-                .withChildValue("baz")
-                .build();
-        final UnmodifiableCollection<?> SchemaAwareleafSetCollection = (UnmodifiableCollection<?>)orderedMapNodeSchemaAware
-                .getValue();
-        final NormalizedNode<?, ?> orderedLeafSetShemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList,
-                (LeafSetNode<?>)orderedLeafSet)
-                .build();
+        final NormalizedNode<?, ?> orderedMapNodeSchemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(
+            leafList).withChildValue("baz").build();
+        final UnmodifiableCollection<?> SchemaAwareleafSetCollection =
+                (UnmodifiableCollection<?>)orderedMapNodeSchemaAware.getValue();
+        final NormalizedNode<?, ?> orderedLeafSetShemaAware = ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(
+            leafList,(LeafSetNode<?>)orderedLeafSet).build();
 
         assertNotNull(Builders.orderedLeafSetBuilder(leafList));
         assertNotNull(Builders.anyXmlBuilder());
@@ -175,7 +174,8 @@ public class BuilderTest {
         collectionNodeBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST);
         collectionNodeBuilder.withValue(mapEntryNodeColl);
         final MapNode mapNode = collectionNodeBuilder.build();
-        final MapNode mapNodeSchemaAware = ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).build();
+        final MapNode mapNodeSchemaAware = ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode())
+                .build();
         assertNotNull(mapNodeSchemaAware);
         assertNotNull(Builders.mapBuilder(mapNode));
     }
@@ -188,8 +188,8 @@ public class BuilderTest {
         final UnkeyedListEntryNode unkeyedListEntryNodeSize = ImmutableUnkeyedListEntryNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
                 .build();
-        final UnkeyedListEntryNode unkeyedListEntryNodeNode = ImmutableUnkeyedListEntryNodeBuilder.create(unkeyedListEntryNode)
-                .build();
+        final UnkeyedListEntryNode unkeyedListEntryNodeNode = ImmutableUnkeyedListEntryNodeBuilder
+                .create(unkeyedListEntryNode).build();
         assertEquals(unkeyedListEntryNode.getNodeType().getLocalName(), unkeyedListEntryNodeSize.getNodeType()
                 .getLocalName());
         assertEquals(unkeyedListEntryNodeSize.getNodeType().getLocalName(), unkeyedListEntryNodeNode.getNodeType()
@@ -203,7 +203,8 @@ public class BuilderTest {
                 .build();
         final ImmutableUnkeyedListNodeBuilder immutableUnkeyedListNodeBuilder = (ImmutableUnkeyedListNodeBuilder)
                 ImmutableUnkeyedListNodeBuilder.create();
-        final UnkeyedListNode unkeyedListNode = immutableUnkeyedListNodeBuilder.withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
+        final UnkeyedListNode unkeyedListNode = immutableUnkeyedListNodeBuilder
+                .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
                 .addChild(unkeyedListEntryNode)
                 .build();
         final UnkeyedListNode unkeyedListNodeSize = ImmutableUnkeyedListNodeBuilder.create(1)
@@ -214,6 +215,7 @@ public class BuilderTest {
         try {
             unkeyedListNodeSize.getChild(1);
         } catch (IndexOutOfBoundsException e) {
+            // Ignored on purpose
         }
 
         assertNotNull(unkeyedListNodeSize.getValue());
@@ -232,12 +234,12 @@ public class BuilderTest {
     }
 
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void immutableAugmentationNodeBuilderExceptionTest() {
         ImmutableAugmentationNodeBuilder.create(1).build();
     }
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void immutableContainerNodeBuilderExceptionTest() {
         final ContainerNode immutableContainerNode = ImmutableContainerNodeBuilder.create(1)
                 .withNodeIdentifier(NODE_IDENTIFIER_LIST)
@@ -249,64 +251,66 @@ public class BuilderTest {
                 .build();
     }
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void immutableLeafSetNodeBuilderExceptionTest() {
-        final LeafSetNode<?> leafSetNode = ImmutableLeafSetNodeBuilder.create(1).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
-                .build();
+        final LeafSetNode<?> leafSetNode = ImmutableLeafSetNodeBuilder.create(1)
+                .withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).build();
         assertNotNull(leafSetNode);
         ImmutableLeafSetNodeSchemaAwareBuilder.create(mock(LeafListSchemaNode.class), leafSetNode).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableLeafSetEntryNodeSchemaAwareBuilderExceptionTest() {
         final LeafListSchemaNode leafListSchemaNode = mock(LeafListSchemaNode.class);
         ImmutableLeafSetEntryNodeSchemaAwareBuilder.create(leafListSchemaNode).withNodeIdentifier(BAR_PATH).build();
     }
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void immutableMapEntryNodeBuilderExceptionTest() {
         ImmutableMapEntryNodeBuilder.create(1).build();
     }
 
-    @Test(expected=NullPointerException.class)
+    @Test(expected = NullPointerException.class)
     public void immutableYangModeledAnyXmlNodeBuilderExceptionTest() {
         ImmutableYangModeledAnyXmlNodeBuilder.create(mock(YangModeledAnyXmlSchemaNode.class), 1);
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableUnkeyedListNodeBuilderExceptionTest() {
         ImmutableUnkeyedListNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LEAF)
                 .removeChild(NODE_IDENTIFIER_LIST).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedMapNotSchemaAwareExceptionTest1() {
         ImmutableOrderedMapNodeBuilder.create(getImmutableMapNode()).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableMapNodeSchemaAwareExceptionTest() {
-        ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).withNodeIdentifier(NODE_IDENTIFIER_LIST).build();
+        ImmutableMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).withNodeIdentifier(NODE_IDENTIFIER_LIST)
+        .build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedMapSchemaAwareExceptionTest1() {
         ImmutableOrderedMapNodeSchemaAwareBuilder.create(list).withNodeIdentifier(NODE_IDENTIFIER_LIST).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedMapSchemaAwareExceptionTest2() {
         ImmutableOrderedMapNodeSchemaAwareBuilder.create(list, getImmutableMapNode()).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedLeafSetNodeExceptionTest1() {
         ImmutableOrderedLeafSetNodeBuilder.create(getImmutableLeafSetNode()).build();
     }
 
-    @Test(expected=UnsupportedOperationException.class)
+    @Test(expected = UnsupportedOperationException.class)
     public void immutableOrderedLeafSetNodeSchemaAwareExceptionTest1() {
-        ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST).build();
+        ImmutableOrderedLeafSetNodeSchemaAwareBuilder.create(leafList).withNodeIdentifier(NODE_IDENTIFIER_LEAF_LIST)
+        .build();
     }
 
     private static LeafSetNode<?> getImmutableLeafSetNode() {
@@ -317,11 +321,12 @@ public class BuilderTest {
     }
 
     private static MapNode getImmutableMapNode() {
-        return ImmutableMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST).withChild(LIST_MAIN_CHILD_1).build();
+        return ImmutableMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST).withChild(LIST_MAIN_CHILD_1)
+                .build();
     }
 
     private static MapNode getImmutableOrderedMapNode() {
-        return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST).withChild(LIST_MAIN_CHILD_1)
-                .build();
+        return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(NODE_IDENTIFIER_LIST)
+                .withChild(LIST_MAIN_CHILD_1).build();
     }
-}
\ No newline at end of file
+}
index 4747d3a2b3074c05b9b2ab621cb5688a6e4b56d6..098420e1c148f49e7189a1d759935c1124a73efd 100644 (file)
@@ -26,6 +26,10 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
@@ -39,10 +43,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 
 public class ImmutableNormalizedNodeStreamWriterTest {
 
@@ -83,8 +83,8 @@ public class ImmutableNormalizedNodeStreamWriterTest {
 
     @Before
     public void setup() throws URISyntaxException, ParseException {
-        bazModule = QNameModule.create(new URI("baz-namespace"), SimpleDateFormatUtil.getRevisionFormat().parse
-                ("1970-01-01"));
+        bazModule = QNameModule.create(new URI("baz-namespace"), SimpleDateFormatUtil.getRevisionFormat()
+            .parse("1970-01-01"));
 
         outerContainer = QName.create(bazModule, "outer-container");
 
@@ -154,7 +154,8 @@ public class ImmutableNormalizedNodeStreamWriterTest {
                         .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInList2))
                                 .withValue("listleafvalue22").build()).build()).build();
 
-        OrderedMapNode myOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(myOrderedList))
+        OrderedMapNode myOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
+            new NodeIdentifier(myOrderedList))
                 .withChild(Builders.mapEntryBuilder().withNodeIdentifier(
                         new NodeIdentifierWithPredicates(myOrderedList, myKeyLeafInOrderedList, "olistkeyvalue1"))
                         .withChild(Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(myLeafInOrderedList1))
index 24081209befc582f1eaa8edc5e05f21a4da64b2e..91a143635843baded91d0348a5183ca229bf2a4b 100644 (file)
@@ -202,4 +202,4 @@ public class InstanceIdToNodesTest {
                 YangInstanceIdentifier.create(rootContainer, leafList, leafListWithValue));
         assertEquals(expectedFilter, filter);
     }
-}
\ No newline at end of file
+}
index 6c3dc7f56b6616235102cda358e69b0a6893ee5c..970425e1f51715b5b50922425b1c52d10eb9f39f 100644 (file)
@@ -66,17 +66,16 @@ public class NormalizedDataBuilderTest {
                 .containerBuilder().withNodeIdentifier(getNodeIdentifier("container"));
 
         // leaf
-        LeafNode<String> leafChild = Builders.<String> leafBuilder().withNodeIdentifier(getNodeIdentifier("leaf"))
+        LeafNode<String> leafChild = Builders.<String>leafBuilder().withNodeIdentifier(getNodeIdentifier("leaf"))
                 .withValue("String").build();
         builder.withChild(leafChild);
 
         // leafList
-        LeafSetNode<Integer> leafList = Builders
-                .<Integer> leafSetBuilder()
+        LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder()
                 .withNodeIdentifier(getNodeIdentifier("leaf"))
                 .withChildValue(1)
                 .withChild(
-                        Builders.<Integer> leafSetEntryBuilder()
+                        Builders.<Integer>leafSetEntryBuilder()
                                 .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
                 .build();
         builder.withChild(leafList);
@@ -85,7 +84,7 @@ public class NormalizedDataBuilderTest {
         MapEntryNode listChild1 = Builders
                 .mapEntryBuilder()
                 .withChild(
-                        Builders.<Integer> leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"))
+                        Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"))
                                 .withValue(1).build())
                 .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build())
                 .withNodeIdentifier(
@@ -109,22 +108,21 @@ public class NormalizedDataBuilderTest {
 
         // This works without schema (adding child from augment as a direct
         // child)
-        builder.withChild(Builders.<Integer> leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
+        builder.withChild(Builders.<Integer>leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
                 .withValue(11).build());
     }
 
     @Test
     public void testSchemaAware() {
-        DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = Builders
-                .containerBuilder(containerNode);
+        DataContainerNodeBuilder<NodeIdentifier, ContainerNode> builder = Builders.containerBuilder(containerNode);
 
         LeafSchemaNode schemaNode = (LeafSchemaNode) getSchemaNode(schema, "test", "uint32");
-        LeafNode<String> leafChild = Builders.<String> leafBuilder(schemaNode).withValue("String").build();
+        LeafNode<String> leafChild = Builders.<String>leafBuilder(schemaNode).withValue("String").build();
         builder.withChild(leafChild);
 
         LeafListSchemaNode leafListSchemaNode = (LeafListSchemaNode) getSchemaNode(schema, "test", "leafList");
-        LeafSetNode<Integer> leafList = Builders.<Integer> leafSetBuilder(leafListSchemaNode).withChildValue(1)
-                .withChild(Builders.<Integer> leafSetEntryBuilder(leafListSchemaNode).withValue(3).build()).build();
+        LeafSetNode<Integer> leafList = Builders.<Integer>leafSetBuilder(leafListSchemaNode).withChildValue(1)
+                .withChild(Builders.<Integer>leafSetEntryBuilder(leafListSchemaNode).withValue(3).build()).build();
         builder.withChild(leafList);
 
         ListSchemaNode listSchema = (ListSchemaNode) getSchemaNode(schema, "test", "list");
@@ -133,7 +131,7 @@ public class NormalizedDataBuilderTest {
                 "containerInList");
 
         MapEntryNode listChild1 = Builders.mapEntryBuilder(listSchema)
-                .withChild(Builders.<Integer> leafBuilder(uint32InListSchemaNode).withValue(1).build())
+                .withChild(Builders.<Integer>leafBuilder(uint32InListSchemaNode).withValue(1).build())
                 .withChild(Builders.containerBuilder(containerInListSchemaNode).build()).build();
 
         MapNode list = ImmutableMapNodeSchemaAwareBuilder.create(listSchema).withChild(listChild1).build();
@@ -144,19 +142,20 @@ public class NormalizedDataBuilderTest {
                 augmentUint32SchemaNode.getQName());
 
         AugmentationNode augmentation = Builders.augmentationBuilder(augmentationSchema)
-                .withChild(Builders.<Integer> leafBuilder(augmentUint32SchemaNode).withValue(11).build()).build();
+                .withChild(Builders.<Integer>leafBuilder(augmentUint32SchemaNode).withValue(11).build()).build();
 
         builder.withChild(augmentation);
 
         // This should fail with schema, since the leaf comes from augmentation
-        // builder.withChild(ImmutableLeafNodeSchemaAwareBuilder.<Integer>get(augmentUint32SchemaNode).withValue(11).build());
+        // builder.withChild(ImmutableLeafNodeSchemaAwareBuilder.<Integer>get(augmentUint32SchemaNode).withValue(11)
+        // .build());
 
         LeafSchemaNode augumentString1SchemaNode = (LeafSchemaNode) getSchemaNode(schema, "test", "augmentString1");
         LeafSchemaNode augumentString2SchemaNode = (LeafSchemaNode) getSchemaNode(schema, "test", "augmentString2");
 
         ChoiceSchemaNode choice1SchemaNode = (ChoiceSchemaNode) getSchemaNode(schema, "test", "choice");
         ChoiceNode choice = ImmutableChoiceNodeSchemaAwareBuilder.create(choice1SchemaNode)
-                .withChild(Builders.<String> leafBuilder(augumentString1SchemaNode).withValue("case1").build())
+                .withChild(Builders.<String>leafBuilder(augumentString1SchemaNode).withValue("case1").build())
                 // This should fail, since child node belongs to different case
                 // .withChild(Builders.<String>leafBuilder(augumentString2SchemaNode).withValue("case2")
                 // .build())
@@ -170,9 +169,9 @@ public class NormalizedDataBuilderTest {
     }
 
     private static AugmentationSchema getAugmentationSchemaForChild(final ContainerSchemaNode containerNode,
-            final QName qName) {
+            final QName qname) {
         for (AugmentationSchema augmentationSchema : containerNode.getAvailableAugmentations()) {
-            if (augmentationSchema.getDataChildByName(qName) != null) {
+            if (augmentationSchema.getDataChildByName(qname) != null) {
                 return augmentationSchema;
             }
         }
index 67d9409d10da4712c9a133d45efc416ce36fd85a..87506e36356f191375e03d6e0294d75bc002f9c7 100644 (file)
@@ -23,11 +23,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
-/**
- *
- * Schema structure of document is
+/*
+ * Schema structure of document is:
  *
- * <pre>
  * container root { 
  *      list list-a {
  *              key leaf-a;
@@ -47,8 +45,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo
  *              }
  *      }
  * }
- * </pre>
- *
  */
 public class NormalizedNodeUtilsTest {
 
@@ -75,7 +71,7 @@ public class NormalizedNodeUtilsTest {
                 .build();
 
     /**
-     * Returns a test document
+     * Returns a test document.
      *
      * <pre>
      * root
@@ -92,7 +88,7 @@ public class NormalizedNodeUtilsTest {
      *
      * @return A test document
      */
-    public NormalizedNode<?, ?> createDocumentOne() {
+    private static NormalizedNode<?, ?> createDocumentOne() {
         return ImmutableContainerNodeBuilder
                 .create()
                 .withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
@@ -119,5 +115,4 @@ public class NormalizedNodeUtilsTest {
         Optional<NormalizedNode<?, ?>> listTwoResult = NormalizedNodes.findNode(tree, LIST_B_TWO_PATH);
         assertTrue(listTwoResult.isPresent());
     }
-
 }
index 9358db5866484700fbf7e904bcccfcdade331ea1..28d9a57456625a0c254c6c1593c79b465bfb1fc5 100644 (file)
@@ -23,8 +23,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class SchemaUtilsTest {
-    private static String NS = "my-namespace";
-    private static String REV = "1970-01-01";
+    private static final String NS = "my-namespace";
+    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -52,28 +52,27 @@ public class SchemaUtilsTest {
         assertTrue(target.iterator().next() instanceof ContainerSchemaNode);
 
         // test l schema nodes (i.e. container and two leafs)
-        Collection<SchemaNode> l = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
+        Collection<SchemaNode> schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-3"), qN("l")));
-        assertEquals(1, l.size());
-        assertTrue(l.iterator().next() instanceof ContainerSchemaNode);
+        assertEquals(1, schema.size());
+        assertTrue(schema.iterator().next() instanceof ContainerSchemaNode);
 
-        l = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
+        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-1"), qN("l")));
-        assertEquals(1, l.size());
-        assertTrue(l.iterator().next() instanceof LeafSchemaNode);
+        assertEquals(1, schema.size());
+        assertTrue(schema.iterator().next() instanceof LeafSchemaNode);
 
-        l = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
+        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name-3"), qN("input"), qN("con-2"), qN("l")));
-        assertTrue(l.isEmpty());
+        assertTrue(schema.isEmpty());
 
-        l = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
+        schema = SchemaUtils.findParentSchemaNodesOnPath(schemaContext,
                 SchemaPath.create(true, qN("my-name-3"), qN("output"), qN("con-2"), qN("l")));
-        assertEquals(1, l.size());
-        assertTrue(l.iterator().next() instanceof LeafSchemaNode);
+        assertEquals(1, schema.size());
+        assertTrue(schema.iterator().next() instanceof LeafSchemaNode);
     }
 
-    private QName qN(final String localName) {
+    private static QName qN(final String localName) {
         return QName.create(NS, REV, localName);
     }
-
 }
index 934fe0345f49e40dd92f3f4af643e4b74e7997b4..d27baf80dc2a7a31f0e71b6552ad604774d50e20 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -16,22 +17,18 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 
 public class AbstractImmutableNormalizedValueAttrNodeTest {
 
-    private static QName ROOT_QNAME = QName.create("urn:test", "2014-03-13",
-            "root");
-    private static QName LEAF_QNAME = QName.create(ROOT_QNAME, "my-leaf");
-    private static QName SAME_LEAF_QNAME = QName.create(ROOT_QNAME, "my-leaf");
-    private static QName OTHER_LEAF_QNAME = QName.create(ROOT_QNAME,
-            "my-other-leaf");
+    private static final QName ROOT_QNAME = QName.create("urn:test", "2014-03-13", "root");
+    private static final QName LEAF_QNAME = QName.create(ROOT_QNAME, "my-leaf");
+    private static final QName SAME_LEAF_QNAME = QName.create(ROOT_QNAME, "my-leaf");
+    private static final QName OTHER_LEAF_QNAME = QName.create(ROOT_QNAME, "my-other-leaf");
 
     @Test
     // This test is based on using different references; we're testing equals()
     @SuppressWarnings({"RedundantStringConstructorCall", "EqualsWithItself"})
     public void equalsByteTest() {
 
-        LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(LEAF_QNAME,
-                null);
-        LeafNode<byte[]> equalLeafNodeNull = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, null);
+        LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(LEAF_QNAME, null);
+        LeafNode<byte[]> equalLeafNodeNull = ImmutableNodes.leafNode(SAME_LEAF_QNAME, null);
 
         assertTrue(leafNodeNull.equals(leafNodeNull));
         assertTrue(leafNodeNull.equals(equalLeafNodeNull));
@@ -41,8 +38,7 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         byte[] equalValue = "test".getBytes();
 
         LeafNode<byte[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
-        LeafNode<byte[]> equalLeafNode = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue);
+        LeafNode<byte[]> equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
 
         assertTrue(leafNode.equals(leafNode));
         assertTrue(leafNode.equals(equalLeafNode));
@@ -53,37 +49,34 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
 
         LeafNode<Byte[]> leafNode2 = ImmutableNodes
                 .leafNode(LEAF_QNAME, value2);
-        LeafNode<Byte[]> equalLeafNode2 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue2);
+        LeafNode<Byte[]> equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
 
         assertTrue(leafNode2.equals(leafNode2));
         assertTrue(leafNode2.equals(equalLeafNode2));
         assertTrue(equalLeafNode2.equals(leafNode2));
 
         byte[][] value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
-        byte[][] equalValue3 = new byte[][] { "test".getBytes(),
-                "test2".getBytes() };
+        byte[][] equalValue3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
 
         LeafNode<byte[][]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME,
                 value3);
-        LeafNode<byte[][]> equalLeafNode3 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue3);
+        LeafNode<byte[][]> equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
 
         assertTrue(leafNode3.equals(leafNode3));
         assertTrue(leafNode3.equals(equalLeafNode3));
         assertTrue(equalLeafNode3.equals(leafNode3));
 
         Byte[][] value4 = new Byte[][] {
-                new Byte[] { new Byte("1"), new Byte("2") },
-                new Byte[] { new Byte("3"), new Byte("4") } };
+            new Byte[] { new Byte("1"), new Byte("2") },
+            new Byte[] { new Byte("3"), new Byte("4") },
+        };
         Byte[][] equalValue4 = new Byte[][] {
-                new Byte[] { new Byte("1"), new Byte("2") },
-                new Byte[] { new Byte("3"), new Byte("4") } };
+            new Byte[] { new Byte("1"), new Byte("2") },
+            new Byte[] { new Byte("3"), new Byte("4") },
+        };
 
-        LeafNode<Byte[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value4);
-        LeafNode<Byte[][]> equalLeafNode4 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue4);
+        LeafNode<Byte[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME,value4);
+        LeafNode<Byte[][]> equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
 
         assertTrue(leafNode4.equals(leafNode4));
         assertTrue(leafNode4.equals(equalLeafNode4));
@@ -103,15 +96,12 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         String value5 = "test";
         String equalValue5 = new String("test");
 
-        LeafNode<String> leafNode5 = ImmutableNodes
-                .leafNode(LEAF_QNAME, value5);
-        LeafNode<String> equalLeafNode5 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue5);
+        LeafNode<String> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        LeafNode<String> equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
 
         assertTrue(leafNode5.equals(leafNode5));
         assertTrue(leafNode5.equals(equalLeafNode5));
         assertTrue(equalLeafNode5.equals(leafNode5));
-
     }
 
     @Test
@@ -123,8 +113,7 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         byte[] equalValue = "test".getBytes();
 
         LeafNode<byte[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
-        LeafNode<byte[]> otherLeafNode = ImmutableNodes.leafNode(
-                OTHER_LEAF_QNAME, equalValue);
+        LeafNode<byte[]> otherLeafNode = ImmutableNodes.leafNode(OTHER_LEAF_QNAME, equalValue);
 
         assertFalse(leafNode.equals(null));
         assertFalse(leafNode.equals(new Object()));
@@ -134,10 +123,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         byte[] value1 = "test".getBytes();
         byte[] otherValue1 = "test1".getBytes();
 
-        LeafNode<byte[]> leafNode1 = ImmutableNodes
-                .leafNode(LEAF_QNAME, value1);
-        LeafNode<byte[]> otherLeafNode1 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue1);
+        LeafNode<byte[]> leafNode1 = ImmutableNodes.leafNode(LEAF_QNAME, value1);
+        LeafNode<byte[]> otherLeafNode1 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue1);
 
         assertFalse(leafNode1.equals(otherLeafNode1));
         assertFalse(otherLeafNode1.equals(leafNode1));
@@ -145,37 +132,32 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         Byte[] value2 = new Byte[] { new Byte("1"), new Byte("1") };
         Byte[] otherValue2 = new Byte[] { new Byte("1"), new Byte("2") };
 
-        LeafNode<Byte[]> leafNode2 = ImmutableNodes
-                .leafNode(LEAF_QNAME, value2);
-        LeafNode<Byte[]> otherLeafNode2 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue2);
+        LeafNode<Byte[]> leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
+        LeafNode<Byte[]> otherLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue2);
 
         assertFalse(leafNode2.equals(otherLeafNode2));
         assertFalse(otherLeafNode2.equals(leafNode2));
 
         byte[][] value3 = new byte[][] { "test".getBytes(), "test2".getBytes() };
-        byte[][] otherValue3 = new byte[][] { "test".getBytes(),
-                "test3".getBytes() };
+        byte[][] otherValue3 = new byte[][] { "test".getBytes(), "test3".getBytes() };
 
-        LeafNode<byte[][]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value3);
-        LeafNode<byte[][]> otherLeafNode3 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue3);
+        LeafNode<byte[][]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
+        LeafNode<byte[][]> otherLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue3);
 
         assertFalse(leafNode3.equals(otherLeafNode3));
         assertFalse(otherLeafNode3.equals(leafNode3));
 
         Byte[][] value4 = new Byte[][] {
-                new Byte[] { new Byte("1"), new Byte("2") },
-                new Byte[] { new Byte("3"), new Byte("4") } };
+            new Byte[] { new Byte("1"), new Byte("2") },
+            new Byte[] { new Byte("3"), new Byte("4") },
+        };
         Byte[][] otherValue4 = new Byte[][] {
-                new Byte[] { new Byte("1"), new Byte("2") },
-                new Byte[] { new Byte("3"), new Byte("5") } };
+            new Byte[] { new Byte("1"), new Byte("2") },
+            new Byte[] { new Byte("3"), new Byte("5") },
+        };
 
-        LeafNode<Byte[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value4);
-        LeafNode<Byte[][]> otherLeafNode4 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue4);
+        LeafNode<Byte[][]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
+        LeafNode<Byte[][]> otherLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue4);
 
         assertFalse(leafNode4.equals(otherLeafNode4));
         assertFalse(otherLeafNode4.equals(leafNode4));
@@ -184,8 +166,7 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         Byte otherValue6 = new Byte("2");
 
         LeafNode<Byte> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
-        LeafNode<Byte> otherLeafNode6 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue6);
+        LeafNode<Byte> otherLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue6);
 
         assertFalse(leafNode6.equals(otherLeafNode6));
         assertFalse(otherLeafNode6.equals(leafNode6));
@@ -193,10 +174,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         String value5 = "test";
         String otherValue5 = "test2";
 
-        LeafNode<String> leafNode5 = ImmutableNodes
-                .leafNode(LEAF_QNAME, value5);
-        LeafNode<String> otherLeafNode5 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, otherValue5);
+        LeafNode<String> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        LeafNode<String> otherLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, otherValue5);
 
         assertFalse(leafNode5.equals(otherLeafNode5));
         assertFalse(otherLeafNode5.equals(leafNode5));
@@ -213,18 +192,15 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         assertFalse(leafNode4.equals(leafNode5));
         assertFalse(leafNode6.equals(leafNode5));
 
-        LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, null);
+        LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(SAME_LEAF_QNAME, null);
         assertFalse(leafNodeNull.equals(leafNode));
         assertFalse(leafNode.equals(leafNodeNull));
 
         byte[] byteValue = new byte[] { 1, 1 };
 
-        LeafNode<byte[]> byteLeafNode = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, byteValue);
+        LeafNode<byte[]> byteLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, byteValue);
         assertFalse(byteLeafNode.equals(leafNode2));
         assertFalse(leafNode2.equals(byteLeafNode));
-
     }
 
     @Test
@@ -235,10 +211,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         char[] valueChar = "test".toCharArray();
         char[] equalValueChar = "test".toCharArray();
 
-        LeafNode<char[]> leafNodeChar = ImmutableNodes.leafNode(LEAF_QNAME,
-                valueChar);
-        LeafNode<char[]> equalLeafNodeChar = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValueChar);
+        LeafNode<char[]> leafNodeChar = ImmutableNodes.leafNode(LEAF_QNAME, valueChar);
+        LeafNode<char[]> equalLeafNodeChar = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValueChar);
 
         assertTrue(leafNodeChar.equals(leafNodeChar));
         assertTrue(leafNodeChar.equals(equalLeafNodeChar));
@@ -247,10 +221,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         boolean[] value = new boolean[] { true, false };
         boolean[] equalValue = new boolean[] { true, false };
 
-        LeafNode<boolean[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME,
-                value);
-        LeafNode<boolean[]> equalLeafNode = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue);
+        LeafNode<boolean[]> leafNode = ImmutableNodes.leafNode(LEAF_QNAME, value);
+        LeafNode<boolean[]> equalLeafNode = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue);
 
         assertTrue(leafNode.equals(leafNode));
         assertTrue(leafNode.equals(equalLeafNode));
@@ -260,8 +232,7 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         int[] equalValue2 = new int[] { 1, 2 };
 
         LeafNode<int[]> leafNode2 = ImmutableNodes.leafNode(LEAF_QNAME, value2);
-        LeafNode<int[]> equalLeafNode2 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue2);
+        LeafNode<int[]> equalLeafNode2 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue2);
 
         assertTrue(leafNode2.equals(leafNode2));
         assertTrue(leafNode2.equals(equalLeafNode2));
@@ -270,10 +241,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         short[] value3 = new short[] { 1, 2 };
         short[] equalValue3 = new short[] { 1, 2 };
 
-        LeafNode<short[]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value3);
-        LeafNode<short[]> equalLeafNode3 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue3);
+        LeafNode<short[]> leafNode3 = ImmutableNodes.leafNode(LEAF_QNAME, value3);
+        LeafNode<short[]> equalLeafNode3 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue3);
 
         assertTrue(leafNode3.equals(leafNode3));
         assertTrue(leafNode3.equals(equalLeafNode3));
@@ -282,10 +251,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         long[] value4 = new long[] { 1, 2 };
         long[] equalValue4 = new long[] { 1, 2 };
 
-        LeafNode<long[]> leafNode4 = ImmutableNodes
-                .leafNode(LEAF_QNAME, value4);
-        LeafNode<long[]> equalLeafNode4 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue4);
+        LeafNode<long[]> leafNode4 = ImmutableNodes.leafNode(LEAF_QNAME, value4);
+        LeafNode<long[]> equalLeafNode4 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue4);
 
         assertTrue(leafNode4.equals(leafNode4));
         assertTrue(leafNode4.equals(equalLeafNode4));
@@ -294,10 +261,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         double[] value6 = new double[] { 1, 2 };
         double[] equalValue6 = new double[] { 1, 2 };
 
-        LeafNode<double[]> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value6);
-        LeafNode<double[]> equalLeafNode6 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue6);
+        LeafNode<double[]> leafNode6 = ImmutableNodes.leafNode(LEAF_QNAME, value6);
+        LeafNode<double[]> equalLeafNode6 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue6);
 
         assertTrue(leafNode6.equals(leafNode6));
         assertTrue(leafNode6.equals(equalLeafNode6));
@@ -306,10 +271,8 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         float[] value5 = new float[] { 1, 2 };
         float[] equalValue5 = new float[] { 1, 2 };
 
-        LeafNode<float[]> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME,
-                value5);
-        LeafNode<float[]> equalLeafNode5 = ImmutableNodes.leafNode(
-                SAME_LEAF_QNAME, equalValue5);
+        LeafNode<float[]> leafNode5 = ImmutableNodes.leafNode(LEAF_QNAME, value5);
+        LeafNode<float[]> equalLeafNode5 = ImmutableNodes.leafNode(SAME_LEAF_QNAME, equalValue5);
 
         assertTrue(leafNode5.equals(leafNode5));
         assertTrue(leafNode5.equals(equalLeafNode5));
@@ -329,5 +292,4 @@ public class AbstractImmutableNormalizedValueAttrNodeTest {
         assertFalse(leafNode5.equals(leafNodeChar));
         assertFalse(leafNode5.equals(leafNode6));
     }
-
 }
index 2751882a45de791df5281b5bc42c0690046657c6..b07d72988d27a785ac18c0d4a09a37e9d3f4cc35 100644 (file)
@@ -22,10 +22,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
@@ -41,10 +41,10 @@ public class Bug4295Test {
     private QName subRoot;
     private QName outerList;
     private QName innerList;
-    private QName oId;
-    private QName iId;
-    private QName oLeaf;
-    private QName iLeaf;
+    private QName oid;
+    private QName iid;
+    private QName oleaf;
+    private QName ileaf;
     private QNameModule foo;
 
     @Before
@@ -57,11 +57,11 @@ public class Bug4295Test {
         subRoot = QName.create(foo, "sub-root");
         outerList = QName.create(foo, "outer-list");
         innerList = QName.create(foo, "inner-list");
-        oId = QName.create(foo, "o-id");
-        iId = QName.create(foo, "i-id");
-        oLeaf = QName.create(foo, "o");
-        iLeaf = QName.create(foo, "i");
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        oid = QName.create(foo, "o-id");
+        iid = QName.create(foo, "i-id");
+        oleaf = QName.create(foo, "o");
+        ileaf = QName.create(foo, "i");
+        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         inMemoryDataTree.setSchemaContext(context);
     }
 
@@ -82,11 +82,8 @@ public class Bug4295Test {
                 .withChild(createOuterListEntry("3", "o-3"))
                 .build();
         ContainerNode rootContainerNode = createRootContainerBuilder()
-        .withChild(
-                createSubRootContainerBuilder()
-                .withChild(outerListNode)
-                .build())
-        .build();
+                .withChild(createSubRootContainerBuilder().withChild(outerListNode).build())
+                .build();
         YangInstanceIdentifier path = YangInstanceIdentifier.of(root);
         DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
         modification.merge(path, rootContainerNode);
@@ -96,7 +93,8 @@ public class Bug4295Test {
             .withChild(createInnerListEntry("a", "i-a"))
             .withChild(createInnerListEntry("b", "i-b"))
             .build();
-        path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2")).node(innerList);
+        path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList).node(createOuterListEntryPath("2"))
+                .node(innerList);
         modification.write(path, innerListNode);
 
         /*  COMMIT */
@@ -105,7 +103,7 @@ public class Bug4295Test {
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modification));
     }
 
-    private void secondModification(int testScenarioNumber) throws DataValidationFailedException {
+    private void secondModification(final int testScenarioNumber) throws DataValidationFailedException {
         /*  MERGE */
         MapNode outerListNode = ImmutableNodes.mapNodeBuilder().withNodeIdentifier(NodeIdentifier.create(outerList))
                 .withChild(createOuterListEntry("3", "o-3"))
@@ -114,11 +112,8 @@ public class Bug4295Test {
                 .build();
 
         ContainerNode rootContainerNode = createRootContainerBuilder()
-        .withChild(
-                createSubRootContainerBuilder()
-                .withChild(outerListNode)
-                .build())
-        .build();
+                .withChild(createSubRootContainerBuilder().withChild(outerListNode).build())
+                .build();
 
         YangInstanceIdentifier path = YangInstanceIdentifier.of(root);
         DataTreeModification modification = inMemoryDataTree.takeSnapshot().newModification();
@@ -148,7 +143,7 @@ public class Bug4295Test {
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modification));
     }
 
-    private void writeEmptyInnerList(DataTreeModification modification, String outerListEntryKey) {
+    private void writeEmptyInnerList(final DataTreeModification modification, final String outerListEntryKey) {
         YangInstanceIdentifier path = YangInstanceIdentifier.of(root).node(subRoot).node(outerList)
                 .node(createOuterListEntryPath(outerListEntryKey)).node(innerList);
         modification.write(path, createInnerListBuilder().build());
@@ -168,25 +163,25 @@ public class Bug4295Test {
         return ImmutableNodes.mapNodeBuilder().withNodeIdentifier(NodeIdentifier.create(innerList));
     }
 
-    private NodeIdentifierWithPredicates createInnerListEntryPath(String keyValue) {
+    private NodeIdentifierWithPredicates createInnerListEntryPath(final String keyValue) {
         Builder<QName, Object> builder = ImmutableMap.builder();
-        ImmutableMap<QName, Object> keys = builder.put(iId, keyValue).build();
+        ImmutableMap<QName, Object> keys = builder.put(iid, keyValue).build();
         return new YangInstanceIdentifier.NodeIdentifierWithPredicates(innerList, keys);
     }
 
-    private NodeIdentifierWithPredicates createOuterListEntryPath(String keyValue) {
+    private NodeIdentifierWithPredicates createOuterListEntryPath(final String keyValue) {
         Builder<QName, Object> builder = ImmutableMap.builder();
-        ImmutableMap<QName, Object> keys = builder.put(oId, keyValue).build();
+        ImmutableMap<QName, Object> keys = builder.put(oid, keyValue).build();
         return new YangInstanceIdentifier.NodeIdentifierWithPredicates(outerList, keys);
     }
 
-    private MapEntryNode createOuterListEntry(String keyValue, String leafValue) {
-        return ImmutableNodes.mapEntryBuilder(outerList, oId, keyValue)
-                .withChild(ImmutableNodes.leafNode(oLeaf, leafValue)).build();
+    private MapEntryNode createOuterListEntry(final String keyValue, final String leafValue) {
+        return ImmutableNodes.mapEntryBuilder(outerList, oid, keyValue)
+                .withChild(ImmutableNodes.leafNode(oleaf, leafValue)).build();
     }
 
-    private MapEntryNode createInnerListEntry(String keyValue, String leafValue) {
-        return ImmutableNodes.mapEntryBuilder(innerList, iId, keyValue)
-                .withChild(ImmutableNodes.leafNode(iLeaf, leafValue)).build();
+    private MapEntryNode createInnerListEntry(final String keyValue, final String leafValue) {
+        return ImmutableNodes.mapEntryBuilder(innerList, iid, keyValue)
+                .withChild(ImmutableNodes.leafNode(ileaf, leafValue)).build();
     }
 }
\ No newline at end of file
index 5313144dd0b5df22019bdfa739a1dd5cd889430f..4181c9afb94cb1d347217afa21edeae202341fd9 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.HashMap;
@@ -64,25 +65,18 @@ public class Bug4454Test {
     private static final YangInstanceIdentifier MIN_MAX_LIST_NO_MINMAX_PATH = YangInstanceIdentifier
             .builder(MASTER_CONTAINER_PATH)
             .node(MIN_MAX_LIST_QNAME_NO_MINMAX).build();
-    private static final YangInstanceIdentifier MIN_MAX_LEAF_LIST_PATH = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
-            .node(MIN_MAX_LEAF_LIST_QNAME).build();
-
-    private static Map<QName,Object> fooPredicates = new HashMap<>();
-    static {
-        fooPredicates.put(MIN_MAX_KEY_LEAF_QNAME,"foo");
-    }
-
-    private static Map<QName,Object> bazPredicates = new HashMap<>();
-    static {
-        bazPredicates.put(MIN_MAX_KEY_LEAF_QNAME,"baz");
-    }
-
-    private final MapEntryNode fooEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new
-            NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, fooPredicates)).
-            withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest")).build();
-    private final MapEntryNode BazEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new
-            NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, bazPredicates)).
-            withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "baztest")).build();
+    private static final YangInstanceIdentifier MIN_MAX_LEAF_LIST_PATH = YangInstanceIdentifier
+            .builder(MASTER_CONTAINER_PATH).node(MIN_MAX_LEAF_LIST_QNAME).build();
+
+    private static final Map<QName, Object> FOO_PREDICATES = ImmutableMap.of(MIN_MAX_KEY_LEAF_QNAME, "foo");
+    private static final Map<QName, Object> BAZ_PREDICATES = ImmutableMap.of(MIN_MAX_KEY_LEAF_QNAME, "baz");
+
+    private final MapEntryNode fooEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(
+        new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, FOO_PREDICATES))
+            .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "footest")).build();
+    private final MapEntryNode bazEntryNodeWithValue = ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(
+        new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, BAZ_PREDICATES))
+            .withChild(ImmutableNodes.leafNode(MIN_MAX_VALUE_LEAF_QNAME, "baztest")).build();
     private final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
             "foo");
     private final MapEntryNode barEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME, MIN_MAX_KEY_LEAF_QNAME,
@@ -91,7 +85,7 @@ public class Bug4454Test {
             "baz");
     private final MapNode mapNodeBazFuzWithNodes = ImmutableNodes.mapNodeBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
-            .withChild(bazEntryNode).withChild(BazEntryNodeWithValue).withChild(fooEntryNode)
+            .withChild(bazEntryNode).withChild(bazEntryNodeWithValue).withChild(fooEntryNode)
             .build();
     private final MapNode mapNodeFooWithNodes = ImmutableNodes.mapNodeBuilder()
             .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME))
@@ -134,7 +128,7 @@ public class Bug4454Test {
 
         NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
+        final YangInstanceIdentifier minMaxLeafFoo = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
                 .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2).build();
 
         key.clear();
@@ -142,8 +136,8 @@ public class Bug4454Test {
 
         mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_NEL = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node
-                (MIN_MAX_LIST_QNAME).node(mapEntryPath2).build();
+        final YangInstanceIdentifier minMaxLeafNel = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
+                .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2).build();
 
         final Map<QName, Object> keyTemp = new HashMap<>();
         keyTemp.put(MIN_MAX_KEY_LEAF_QNAME, "baz");
@@ -164,7 +158,8 @@ public class Bug4454Test {
         keyTemp.clear();
         keyTemp.put(MIN_MAX_KEY_LEAF_QNAME, "foo");
 
-        final NodeIdentifierWithPredicates mapEntryPathTestKey = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , keyTemp);
+        final NodeIdentifierWithPredicates mapEntryPathTestKey = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME,
+            keyTemp);
 
         final YangInstanceIdentifier pathToKeyFoo = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
                 .node(MIN_MAX_LIST_QNAME).node(mapEntryPathTestKey).node(MIN_MAX_KEY_LEAF_QNAME).build();
@@ -189,8 +184,8 @@ public class Bug4454Test {
         modificationTree1.write(pathToBaz, newNode2);
         modificationTree1.write(pathToBaz, newNode1);
         modificationTree1.write(pathToBaz, newNode);
-        modificationTree1.delete(MIN_MAX_LEAF_FOO);
-        modificationTree1.delete(MIN_MAX_LEAF_NEL);
+        modificationTree1.delete(minMaxLeafFoo);
+        modificationTree1.delete(minMaxLeafNel);
 
         modificationTree1.ready();
         inMemoryDataTree.validate(modificationTree1);
@@ -295,8 +290,8 @@ public class Bug4454Test {
         final InMemoryDataTreeSnapshot snapshotAfterCommit = inMemoryDataTree.takeSnapshot();
         final Optional<NormalizedNode<?, ?>> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH);
         assertTrue(masterContainer.isPresent());
-        final Optional<NormalizedNodeContainer<?, ?, ?>> leafList = ((NormalizedNodeContainer) masterContainer.get()).getChild(
-                new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
+        final Optional<NormalizedNodeContainer<?, ?, ?>> leafList = ((NormalizedNodeContainer) masterContainer.get())
+                .getChild(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
         assertTrue(leafList.isPresent());
         assertTrue(leafList.get().getValue().size() == 3);
     }
@@ -309,35 +304,33 @@ public class Bug4454Test {
         Map<QName, Object> key = new HashMap<>();
         key.put(MIN_MAX_KEY_LEAF_QNAME, "foo");
 
-        NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME , key);
+        NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
-                .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2).build();
+        final YangInstanceIdentifier minMaxLeafFoo = MASTER_CONTAINER_PATH
+                .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
 
         key.clear();
         key.put(MIN_MAX_KEY_LEAF_QNAME, "bar");
 
         mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_BAR = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node
-                (MIN_MAX_LIST_QNAME)
-                .node(mapEntryPath2).build();
+        final YangInstanceIdentifier minMaxLeafBar = MASTER_CONTAINER_PATH
+                .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
 
         key.clear();
         key.put(MIN_MAX_KEY_LEAF_QNAME, "baz");
 
         mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME, key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_BAZ = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node
-                (MIN_MAX_LIST_QNAME)
-                .node(mapEntryPath2).build();
+        final YangInstanceIdentifier minMaxLeafBaz = MASTER_CONTAINER_PATH
+                .node(MIN_MAX_LIST_QNAME).node(mapEntryPath2);
 
         modificationTree.write(MIN_MAX_LIST_PATH, mapNodeFooWithNodes);
         modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBar);
         modificationTree.merge(MIN_MAX_LIST_PATH, mapNodeBaz);
-        modificationTree.delete(MIN_MAX_LEAF_FOO);
-        modificationTree.delete(MIN_MAX_LEAF_BAR);
-        modificationTree.delete(MIN_MAX_LEAF_BAZ);
+        modificationTree.delete(minMaxLeafFoo);
+        modificationTree.delete(minMaxLeafBar);
+        modificationTree.delete(minMaxLeafBaz);
 
         modificationTree.ready();
 
@@ -348,8 +341,8 @@ public class Bug4454Test {
 
     @Test
     public void minMaxListNoMinMaxDeleteTest() throws DataValidationFailedException {
-        final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME
-                , "foo");
+        final MapEntryNode fooEntryNode = ImmutableNodes.mapEntry(MIN_MAX_LIST_QNAME_NO_MINMAX, MIN_MAX_KEY_LEAF_QNAME,
+            "foo");
         final MapNode mapNode1 = ImmutableNodes.mapNodeBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MIN_MAX_LIST_QNAME_NO_MINMAX))
                 .withChild(fooEntryNode).build();
@@ -359,23 +352,23 @@ public class Bug4454Test {
         Map<QName, Object> key = new HashMap<>();
         key.put(MIN_MAX_KEY_LEAF_QNAME, "foo");
 
-        NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX , key);
+        NodeIdentifierWithPredicates mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX,
+            key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_FOO = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node
-                (MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2).build();
+        final YangInstanceIdentifier minMaxLeafFoo = MASTER_CONTAINER_PATH
+                .node(MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2);
 
         key.clear();
         key.put(MIN_MAX_KEY_LEAF_QNAME, "non-existing-leaf");
 
         mapEntryPath2 = new NodeIdentifierWithPredicates(MIN_MAX_LIST_QNAME_NO_MINMAX, key);
 
-        YangInstanceIdentifier MIN_MAX_LEAF_NEL = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH).node
-                (MIN_MAX_LIST_QNAME_NO_MINMAX)
-                .node(mapEntryPath2).build();
+        YangInstanceIdentifier minMaxLeafNel = YangInstanceIdentifier.builder(MASTER_CONTAINER_PATH)
+                .node(MIN_MAX_LIST_QNAME_NO_MINMAX).node(mapEntryPath2).build();
 
         modificationTree.write(MIN_MAX_LIST_NO_MINMAX_PATH, mapNode1);
-        modificationTree.delete(MIN_MAX_LEAF_FOO);
-        modificationTree.delete(MIN_MAX_LEAF_NEL);
+        modificationTree.delete(minMaxLeafFoo);
+        modificationTree.delete(minMaxLeafNel);
 
         modificationTree.ready();
 
@@ -396,7 +389,7 @@ public class Bug4454Test {
         UnmodifiableCollection<?> collectionChildren = (UnmodifiableCollection<?>) minMaxListRead.get().getValue();
 
         for (Object collectionChild : collectionChildren) {
-            if (collectionChild.toString().contains(first)){
+            if (collectionChild.toString().contains(first)) {
                 assertTrue(collectionChild.toString().contains(first));
             } else {
                 assertTrue(collectionChild.toString().contains(second));
index f16bdc5630a423c37e37bb4b8b1d2b0017238748..d658053f2dc94347ea415eb2899bfa2b53d4ffe7 100644 (file)
@@ -23,8 +23,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
@@ -49,7 +49,7 @@ public class Bug5830Test {
     private static InMemoryDataTree initDataTree(final SchemaContext schemaContext)
             throws DataValidationFailedException {
         InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+                DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
 
         final MapNode taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
@@ -205,8 +205,8 @@ public class Bug5830Test {
         inMemoryDataTree.commit(prepare);
     }
 
-    private static void testMandatoryLeaf2IsPresent(final SchemaContext schemaContext, final boolean withPresenceContianer)
-            throws DataValidationFailedException {
+    private static void testMandatoryLeaf2IsPresent(final SchemaContext schemaContext,
+            final boolean withPresenceContianer) throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
 
         final MapEntryNode taskEntryNode = Builders.mapEntryBuilder()
index 72ae13fbd8edec1283357c1c232d2f62d54dda08..79568b97be02ae01daf9a89fd25ae17bdba75786 100644 (file)
@@ -142,8 +142,8 @@ public class Bug5968MergeTest {
         }
     }
 
-    private static void mergeMap(final InMemoryDataTreeModification modificationTree, final boolean mandatoryDataMissing)
-            throws DataValidationFailedException {
+    private static void mergeMap(final InMemoryDataTreeModification modificationTree,
+            final boolean mandatoryDataMissing) throws DataValidationFailedException {
         final MapNode myList = createMap(mandatoryDataMissing);
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), myList);
     }
@@ -292,12 +292,11 @@ public class Bug5968MergeTest {
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue));
     }
 
-    private static CollectionNodeBuilder<MapEntryNode, MapNode> createMapBuilder() throws DataValidationFailedException {
+    private static CollectionNodeBuilder<MapEntryNode, MapNode> createMapBuilder() {
         return Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(MY_LIST));
     }
 
-    private static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createContainerBuilder()
-            throws DataValidationFailedException {
+    private static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createContainerBuilder() {
         return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ROOT));
     }
 
index 523d7d2473da85575603680595b3fb419d98e128..620342422c2e2f7316e2dad6a5005614b480c615 100644 (file)
@@ -141,13 +141,13 @@ public class Bug5968Test {
         }
     }
 
-    private static void writeMap(final InMemoryDataTreeModification modificationTree, final boolean mandatoryDataMissing)
-            throws DataValidationFailedException {
+    private static void writeMap(final InMemoryDataTreeModification modificationTree,
+            final boolean mandatoryDataMissing) {
         final MapNode myList = createMap(mandatoryDataMissing);
         modificationTree.write(YangInstanceIdentifier.of(ROOT).node(MY_LIST), myList);
     }
 
-    private static MapNode createMap(final boolean mandatoryDataMissing) throws DataValidationFailedException {
+    private static MapNode createMap(final boolean mandatoryDataMissing) {
         return Builders
                 .mapBuilder()
                 .withNodeIdentifier(new NodeIdentifier(MY_LIST))
@@ -168,7 +168,7 @@ public class Bug5968Test {
     }
 
     private static MapEntryNode createMapEntry(final Object listIdValue, final Object mandatoryLeafValue,
-            final Object commonLeafValue) throws DataValidationFailedException {
+            final Object commonLeafValue) {
         return Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
@@ -176,8 +176,7 @@ public class Bug5968Test {
                 .withChild(ImmutableNodes.leafNode(COMMON_LEAF, commonLeafValue)).build();
     }
 
-    private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue)
-            throws DataValidationFailedException {
+    private static MapEntryNode createMapEntry(final Object listIdValue, final Object commonLeafValue) {
         return Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, listIdValue)))
                 .withChild(ImmutableNodes.leafNode(LIST_ID, listIdValue))
index 282aa3caabcf8a4591d8984caa802fe5a74e022f..9a2c370fc455ec1abb2f11584a914ddb3c2bf701 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
+
 import com.google.common.collect.ImmutableSet;
 import org.junit.Before;
 import org.junit.Test;
@@ -22,22 +26,17 @@ import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
-
 public class CaseAugmentTest {
 
     private SchemaContext schemaContext;
-    private final QName CHOICE1_QNAME = QName.create(TestModel.TEST_QNAME, "choice1");
-    private final QName C1L1_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf1");
-    private final QName C1L2_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf2");
-    private final QName C1L3_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf3");
-    private final QName C2L1_QNAME = QName.create(TestModel.TEST_QNAME, "case2-leaf1");
-    private final NodeIdentifier CHOICE_ID = new NodeIdentifier(CHOICE1_QNAME);
-    private final AugmentationIdentifier AUGMENT_ID =
-            new AugmentationIdentifier(ImmutableSet.<QName>builder().add(C1L2_QNAME).add(C1L3_QNAME).build());
-
+    private static final QName CHOICE1_QNAME = QName.create(TestModel.TEST_QNAME, "choice1");
+    private static final QName C1L1_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf1");
+    private static final QName C1L2_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf2");
+    private static final QName C1L3_QNAME = QName.create(TestModel.TEST_QNAME, "case1-leaf3");
+    private static final QName C2L1_QNAME = QName.create(TestModel.TEST_QNAME, "case2-leaf1");
+    private static final NodeIdentifier CHOICE_ID = new NodeIdentifier(CHOICE1_QNAME);
+    private static final AugmentationIdentifier AUGMENT_ID = new AugmentationIdentifier(
+        ImmutableSet.of(C1L2_QNAME, C1L3_QNAME));
 
     @Before
     public void prepare() throws ReactorException {
index f02428ccb34b99ca93bb304ece5687923462ee64..657f4cf52cfd2b42d04fa1051131fede7c494975 100644 (file)
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntryBuilder;
 import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapNodeBuilder;
+
 import com.google.common.base.Optional;
 import org.junit.Before;
 import org.junit.Test;
@@ -23,9 +24,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -39,22 +40,22 @@ public class ConcurrentTreeModificationTest {
     private static final Short ONE_ID = 1;
     private static final Short TWO_ID = 2;
 
-    private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier.builder(
+        TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
             .build();
 
-    private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier.builder(
+        TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
-    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME) //
-                    .build()) //
+    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).build())
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME) //
-                    .build()) //
+    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).build())
             .build();
 
     private SchemaContext schemaContext;
@@ -64,13 +65,13 @@ public class ConcurrentTreeModificationTest {
     public void prepare() throws ReactorException {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
+            DataTreeConfiguration.DEFAULT_OPERATIONAL);
         inMemoryDataTree.setSchemaContext(schemaContext);
     }
 
     private static ContainerNode createFooTestContainerNode() {
-        return ImmutableContainerNodeBuilder
-                .create()
+        return ImmutableContainerNodeBuilder.create()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
                 .withChild(
                         mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
@@ -450,7 +451,8 @@ public class ConcurrentTreeModificationTest {
     public void writeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -480,7 +482,8 @@ public class ConcurrentTreeModificationTest {
     public void writeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -510,7 +513,8 @@ public class ConcurrentTreeModificationTest {
     public void mergeWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -540,7 +544,8 @@ public class ConcurrentTreeModificationTest {
     public void mergeMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -570,7 +575,8 @@ public class ConcurrentTreeModificationTest {
     public void deleteWriteFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -592,8 +598,8 @@ public class ConcurrentTreeModificationTest {
             final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
             inMemoryDataTree.commit(prepare2);
             fail("Exception should have been thrown");
-        } catch (final Exception e) {
-            LOG.debug("Exception was thrown because path no longer exist in tree");
+        } catch (final ConflictingModificationAppliedException e) {
+            LOG.debug("Exception was thrown because path no longer exist in tree", e);
         }
 
         final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
@@ -604,7 +610,8 @@ public class ConcurrentTreeModificationTest {
     public void deleteMergeFooBar2ndLevelEmptyContainerTest() throws DataValidationFailedException {
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        initialDataTreeModification.write(TestModel.OUTER_LIST_PATH, mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
         final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
@@ -626,8 +633,8 @@ public class ConcurrentTreeModificationTest {
             final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
             inMemoryDataTree.commit(prepare2);
             fail("Exception should have been thrown");
-        } catch (final Exception e) {
-            LOG.debug("Exception was thrown because path no longer exist in tree");
+        } catch (final ConflictingModificationAppliedException e) {
+            LOG.debug("Exception was thrown because path no longer exist in tree", e);
         }
 
         final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
index eed8728b32f15dc5f73a387a774521a947110b54..d2da63d0f0f5bd3c246a93883277b889f000575b 100644 (file)
@@ -22,8 +22,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
@@ -36,11 +36,11 @@ public class ConfigStatementValidationTest {
     private static final Short TWO_ID = 2;
 
     private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier
-            .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
+            .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
             .build();
 
     private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier
-            .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
+            .builder(TestModel.OUTER_LIST_PATH).nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
     private static final MapEntryNode INNER_FOO_ENTRY_NODE = ImmutableNodes.mapEntry(TestModel.INNER_LIST_QNAME,
@@ -50,14 +50,14 @@ public class ConfigStatementValidationTest {
             .mapEntryBuilder(QName.create(TestModel.TEST_QNAME, "inner-list2"), TestModel.NAME_QNAME, "foo")
             .withChild(ImmutableNodes.leafNode(TestModel.VALUE_QNAME, "value")).build();
 
-    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_FOO_ENTRY_NODE) //
-                    .build()) //
+    private static final MapEntryNode FOO_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_FOO_ENTRY_NODE)
+                    .build())
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_BAR_ENTRY_NODE) //
-                    .build()) //
+    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME).withChild(INNER_BAR_ENTRY_NODE)
+                    .build())
             .build();
 
     private SchemaContext schemaContext;
@@ -83,7 +83,7 @@ public class ConfigStatementValidationTest {
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnPathFail() throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+            DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
         final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         final YangInstanceIdentifier ii = OUTER_LIST_1_PATH.node(
@@ -99,7 +99,7 @@ public class ConfigStatementValidationTest {
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnDataFail() throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+            DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
         final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, createFooTestContainerNode());
@@ -112,7 +112,7 @@ public class ConfigStatementValidationTest {
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnDataLeafFail() throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+            DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
         final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, createBarTestContainerNode());
@@ -125,7 +125,7 @@ public class ConfigStatementValidationTest {
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnPathCaseLeafFail() throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+            DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
         final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
                 TestModel.TEST_QNAME, "choice1"));
@@ -146,7 +146,7 @@ public class ConfigStatementValidationTest {
     @Test(expected = VerifyException.class)
     public void testOnDataCaseLeafFail() throws DataValidationFailedException {
         final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                TreeType.CONFIGURATION);
+            DataTreeConfiguration.DEFAULT_CONFIGURATION);
         inMemoryDataTree.setSchemaContext(schemaContext);
         final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
                 TestModel.TEST_QNAME, "choice1"));
index e3160a839c4f096ef811e8247b65c5d6eabccf7c..573c622498846d413bec933d6318003873abbdc0 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
@@ -39,7 +40,7 @@ public class DataTreeCandidatesTest {
 
     @Before
     public void setUp() throws Exception {
-        dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        dataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         dataTree.setSchemaContext(SCHEMA_CONTEXT);
 
         final ContainerNode testContainer = ImmutableContainerNodeBuilder.create()
@@ -49,7 +50,8 @@ public class DataTreeCandidatesTest {
                         .build())
                 .build();
 
-        final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) dataTree.takeSnapshot().newModification();
+        final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) dataTree.takeSnapshot()
+                .newModification();
         final DataTreeModificationCursor cursor = modification.createCursor(YangInstanceIdentifier.EMPTY);
         cursor.write(TestModel.TEST_PATH.getLastPathArgument(), testContainer);
         modification.ready();
@@ -61,7 +63,8 @@ public class DataTreeCandidatesTest {
 
     @Test
     public void testRootedCandidate() throws Exception {
-        final DataTree innerDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL, TestModel.INNER_CONTAINER_PATH);
+        final DataTree innerDataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL,
+            TestModel.INNER_CONTAINER_PATH);
         innerDataTree.setSchemaContext(SCHEMA_CONTEXT);
 
         final LeafNode<String> leaf = ImmutableLeafNodeBuilder.<String>create()
@@ -69,7 +72,8 @@ public class DataTreeCandidatesTest {
                 .withValue("testing-value")
                 .build();
 
-        final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) innerDataTree.takeSnapshot().newModification();
+        final InMemoryDataTreeModification modification = (InMemoryDataTreeModification) innerDataTree.takeSnapshot()
+                .newModification();
         modification.write(TestModel.VALUE_PATH, leaf);
 
         modification.ready();
@@ -78,7 +82,8 @@ public class DataTreeCandidatesTest {
         dataTree.commit(candidate);
 
         final DataTreeModification newModification = dataTree.takeSnapshot().newModification();
-        final DataTreeCandidate newCandidate = DataTreeCandidates.newDataTreeCandidate(TestModel.INNER_CONTAINER_PATH, candidate.getRootNode());
+        final DataTreeCandidate newCandidate = DataTreeCandidates.newDataTreeCandidate(TestModel.INNER_CONTAINER_PATH,
+            candidate.getRootNode());
 
         try {
             // lets see if getting the identifier of the root node throws an exception
index ceabb7a9bff1aba1ad8422f9b1b870f2a7682a7b..c3b686ad3185250aa094c2450945f04d566ccc89 100644 (file)
@@ -38,13 +38,13 @@ public class DataTreeTransactionTest {
         tree.prepare(mod);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testUnsealedValidate() throws DataValidationFailedException {
         final DataTreeModification mod = tree.takeSnapshot().newModification();
         tree.validate(mod);
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testUnsealedPrepare() {
         final DataTreeModification mod = tree.takeSnapshot().newModification();
         tree.prepare(mod);
index c495f035d9e4e55b50ad553c044957b8c115c2cc..2618589f1bd479412c8bd632e8e2d531d35bd64c 100644 (file)
@@ -9,12 +9,13 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
@@ -24,7 +25,8 @@ public class ErrorReportingTest {
 
     @Before
     public void setup() throws ReactorException {
-        tree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        tree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
+            DataTreeConfiguration.DEFAULT_OPERATIONAL);
         tree.setSchemaContext(TestModel.createTestContext());
     }
 
@@ -32,7 +34,8 @@ public class ErrorReportingTest {
     public void writeWithoutParentExisting() {
         InMemoryDataTreeModification modification = tree.takeSnapshot().newModification();
         // We write node without creating parent
-        modification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        modification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
         modification.ready();
         try {
             tree.validate(modification);
@@ -53,8 +56,8 @@ public class ErrorReportingTest {
         // We commit transaction
         tree.commit(tree.prepare(initial));
 
-        InMemoryDataTreeModification writeTx = tree.takeSnapshot().newModification();
-        InMemoryDataTreeModification deleteTx = tree.takeSnapshot().newModification();
+        final InMemoryDataTreeModification writeTx = tree.takeSnapshot().newModification();
+        final InMemoryDataTreeModification deleteTx = tree.takeSnapshot().newModification();
         deleteTx.delete(TestModel.TEST_PATH);
         deleteTx.ready();
         // We commit delete modification
@@ -70,6 +73,5 @@ public class ErrorReportingTest {
         } catch (DataValidationFailedException e) {
             fail("ConflictingModificationAppliedException expected");
         }
-
     }
 }
index 539e90f84d9fcc8c66e28702c26a01d8c0e47e91..ef99fefa19cac2822a3b22c27ec454fe7e3e35db 100644 (file)
@@ -38,17 +38,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUn
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ListConstraintsValidation {
-    private static final Logger LOG = LoggerFactory.getLogger(ListConstraintsValidation.class);
-
     private static final String CONSTRAINTS_VALIDATION_TEST_YANG = "/list-constraints-validation-test-model.yang";
-    private SchemaContext schemaContext;
-
-    private InMemoryDataTree inMemoryDataTree;
-
     private static final QName MASTER_CONTAINER_QNAME = QName.create(
             "urn:opendaylight:params:xml:ns:yang:list-constraints-validation-test-model", "2015-02-02",
             "master-container");
@@ -74,6 +66,9 @@ public class ListConstraintsValidation {
     private static final YangInstanceIdentifier UNKEYED_LIST_PATH = YangInstanceIdentifier
             .builder(MASTER_CONTAINER_PATH).node(UNKEYED_LIST_QNAME).build();
 
+    private SchemaContext schemaContext;
+    private InMemoryDataTree inMemoryDataTree;
+
     @Before
     public void prepare() {
         schemaContext = createTestContext();
@@ -120,7 +115,7 @@ public class ListConstraintsValidation {
         assertTrue(((NormalizedNodeContainer<?, ?, ?>) minMaxListRead.get()).getValue().size() == 2);
     }
 
-    @Test(expected=DataValidationFailedException.class)
+    @Test(expected = DataValidationFailedException.class)
     public void minMaxListFail() throws DataValidationFailedException {
         InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
@@ -203,13 +198,13 @@ public class ListConstraintsValidation {
         final InMemoryDataTreeSnapshot snapshotAfterCommit = inMemoryDataTree.takeSnapshot();
         final Optional<NormalizedNode<?, ?>> masterContainer = snapshotAfterCommit.readNode(MASTER_CONTAINER_PATH);
         assertTrue(masterContainer.isPresent());
-        final Optional<NormalizedNodeContainer<?, ?, ?>> leafList = ((NormalizedNodeContainer) masterContainer.get()).getChild(
-                new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
+        final Optional<NormalizedNodeContainer<?, ?, ?>> leafList = ((NormalizedNodeContainer) masterContainer.get())
+                .getChild(new NodeIdentifier(MIN_MAX_LEAF_LIST_QNAME));
         assertTrue(leafList.isPresent());
         assertTrue(leafList.get().getValue().size() == 2);
     }
 
-    @Test(expected=DataValidationFailedException.class)
+    @Test(expected = DataValidationFailedException.class)
     public void minMaxLeafListFail() throws DataValidationFailedException {
         final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
@@ -268,7 +263,7 @@ public class ListConstraintsValidation {
         assertTrue(((UnkeyedListNode) unkeyedListRead.get()).getSize() == 1);
     }
 
-    @Test(expected=DataValidationFailedException.class)
+    @Test(expected = DataValidationFailedException.class)
     public void unkeyedListTestFail() throws DataValidationFailedException {
         final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
index b26420eefd29b09eb80def913ebfed7e6ec3668f..12168b9d1b0b9ca88b0af9df56f9c8cc254d5dab 100644 (file)
@@ -140,8 +140,9 @@ public class MandatoryLeafTest {
             final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
             inMemoryDataTree.commit(prepare);
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)choice1 is missing mandatory descendant /(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)case2-cont/case2-leaf1",
+            assertEquals("Node (urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?"
+                    + "revision=2014-03-13)choice1 is missing mandatory descendant /(urn:opendaylight:params:xml:ns:"
+                    + "yang:controller:md:sal:dom:store:test?revision=2014-03-13)case2-cont/case2-leaf1",
                     e.getMessage());
             throw e;
         }
@@ -210,8 +211,9 @@ public class MandatoryLeafTest {
             final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
             inMemoryDataTree.commit(prepare2);
         } catch (final IllegalArgumentException e) {
-            assertEquals(
-                    "Node (urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)choice1 is missing mandatory descendant /(urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?revision=2014-03-13)case2-cont/case2-leaf1",
+            assertEquals("Node (urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test?"
+                    + "revision=2014-03-13)choice1 is missing mandatory descendant /(urn:opendaylight:params:xml:ns:"
+                    + "yang:controller:md:sal:dom:store:test?revision=2014-03-13)case2-cont/case2-leaf1",
                     e.getMessage());
             throw e;
         }
index 0f1ead33089e0b08c1ec8db868116e3350545b44..ff85274bb2ffd06e02b77a9bfaad2b36a7f65604 100644 (file)
@@ -28,7 +28,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
@@ -36,11 +35,9 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-/**
- *
+/*
  * Schema structure of document is
  *
- * <pre>
  * container root { 
  *      list list-a {
  *              key leaf-a;
@@ -60,8 +57,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
  *              }
  *      }
  * }
- * </pre>
- *
  */
 public class ModificationMetadataTreeTest {
 
@@ -70,28 +65,30 @@ public class ModificationMetadataTreeTest {
     private static final String TWO_ONE_NAME = "one";
     private static final String TWO_TWO_NAME = "two";
 
-    private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_1_PATH =
+            YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
             .build();
 
-    private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_2_PATH =
+            YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
     private static final YangInstanceIdentifier TWO_TWO_PATH = YangInstanceIdentifier.builder(OUTER_LIST_2_PATH)
-            .node(TestModel.INNER_LIST_QNAME) //
-            .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME) //
+            .node(TestModel.INNER_LIST_QNAME)
+            .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)
             .build();
 
     private static final YangInstanceIdentifier TWO_TWO_VALUE_PATH = YangInstanceIdentifier.builder(TWO_TWO_PATH)
-            .node(TestModel.VALUE_QNAME) //
+            .node(TestModel.VALUE_QNAME)
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME) //
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME)) //
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME)) //
-                    .build()) //
+    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME,TestModel.NAME_QNAME, TWO_TWO_NAME))
+                    .build())
                     .build();
 
     private SchemaContext schemaContext;
@@ -101,12 +98,12 @@ public class ModificationMetadataTreeTest {
     public void prepare() throws ReactorException {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext, DataTreeConfiguration.DEFAULT_OPERATIONAL));
+        rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext,
+            DataTreeConfiguration.DEFAULT_OPERATIONAL));
     }
 
     /**
-     * Returns a test document
-     *
+     * Returns a test document.
      * <pre>
      * test
      *     outer-list
@@ -142,9 +139,9 @@ public class ModificationMetadataTreeTest {
 
     @Test
     public void basicReadWrites() {
-        final DataTreeModification modificationTree = new InMemoryDataTreeModification(new InMemoryDataTreeSnapshot(schemaContext,
-                TreeNodeFactory.createTreeNodeRecursively(createDocumentOne(), Version.initial()), rootOper),
-                rootOper);
+        final DataTreeModification modificationTree = new InMemoryDataTreeModification(
+            new InMemoryDataTreeSnapshot(schemaContext,
+                TreeNodeFactory.createTreeNodeRecursively(createDocumentOne(), Version.initial()), rootOper), rootOper);
         final Optional<NormalizedNode<?, ?>> originalBarNode = modificationTree.readNode(OUTER_LIST_2_PATH);
         assertTrue(originalBarNode.isPresent());
         assertSame(BAR_NODE, originalBarNode.get());
@@ -169,7 +166,7 @@ public class ModificationMetadataTreeTest {
         /**
          * Creates empty Snapshot with associated schema context.
          */
-        final DataTree t = InMemoryDataTreeFactory.getInstance().create(TreeType.OPERATIONAL);
+        final DataTree t = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
         t.setSchemaContext(schemaContext);
 
         /**
@@ -185,27 +182,18 @@ public class ModificationMetadataTreeTest {
     public void createFromEmptyState() {
 
         final DataTreeModification modificationTree = createEmptyModificationTree();
-        /**
-         * Writes empty container node to /test
-         *
-         */
+        // Writes empty container node to /test
         modificationTree.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
 
-        /**
-         * Writes empty list node to /test/outer-list
-         */
-        modificationTree.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
+        // Writes empty list node to /test/outer-list
+        modificationTree.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+            .build());
 
-        /**
-         * Reads list node from /test/outer-list
-         */
+        // Reads list node from /test/outer-list.
         final Optional<NormalizedNode<?, ?>> potentialOuterList = modificationTree.readNode(TestModel.OUTER_LIST_PATH);
         assertTrue(potentialOuterList.isPresent());
 
-        /**
-         * Reads container node from /test and verifies that it contains test
-         * node
-         */
+        // Reads container node from /test and verifies that it contains test node.
         final Optional<NormalizedNode<?, ?>> potentialTest = modificationTree.readNode(TestModel.TEST_PATH);
         final ContainerNode containerTest = assertPresentAndType(potentialTest, ContainerNode.class);
 
@@ -216,7 +204,6 @@ public class ModificationMetadataTreeTest {
          *
          */
         assertPresentAndType(containerTest.getChild(new NodeIdentifier(TestModel.OUTER_LIST_QNAME)), MapNode.class);
-
     }
 
     @Test
@@ -248,5 +235,4 @@ public class ModificationMetadataTreeTest {
         assertTrue(type.isInstance(potential.get()));
         return type.cast(potential.get());
     }
-
 }
index 8ac4fe86bbe69b0b90e629f869c4375913b82329..0d0b526baef8060529060957a8a86126b5293315 100644 (file)
@@ -22,8 +22,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -41,7 +41,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OrderedListTest {
-    private Logger LOG = LoggerFactory.getLogger(OrderedListTest.class);
+    private static final Logger LOG = LoggerFactory.getLogger(OrderedListTest.class);
 
     private TipProducingDataTree inMemoryDataTree;
     private SchemaContext context;
@@ -146,8 +146,8 @@ public class OrderedListTest {
                 .withChild(createChildOrderedListEntry("chkval2", "chlfval2updated"))
                 .withChild(createChildOrderedListEntry("chkval3", "chlfval3")).build();
 
-        YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer).node
-                (parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
+        YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer)
+                .node(parentOrderedList).node(createParentOrderedListEntryPath("pkval2")).node(childOrderedList);
         treeModification.merge(path2, childOrderedListNode);
 
         treeModification.ready();
@@ -181,8 +181,8 @@ public class OrderedListTest {
                 new NodeIdentifier(childOrderedList))
                 .withChild(createChildOrderedListEntry("chkval1", "chlfval1new")).build();
 
-        YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer).node
-                (parentOrderedList)
+        YangInstanceIdentifier path2 = YangInstanceIdentifier.of(parentContainer).node(childContainer)
+                .node(parentOrderedList)
                 .node(createParentOrderedListEntryPath("pkval4")).node(childOrderedList);
 
         treeModification.merge(path2, childOrderedListNode);
@@ -209,17 +209,18 @@ public class OrderedListTest {
         DataTreeModification treeModification1 = inMemoryDataTree.takeSnapshot().newModification();
         DataTreeModification treeModification2 = inMemoryDataTree.takeSnapshot().newModification();
 
-        OrderedMapNode parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(new
-                NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval1",
-                "plfval1")).build();
+        OrderedMapNode parentOrderedListNode = Builders.orderedMapBuilder().withNodeIdentifier(
+            new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval1", "plfval1"))
+                .build();
 
-        OrderedMapNode parentOrderedListNode2 = Builders.orderedMapBuilder().withNodeIdentifier(new
-                NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval2",
-                "plfval2")).build();
+        OrderedMapNode parentOrderedListNode2 = Builders.orderedMapBuilder().withNodeIdentifier(
+            new NodeIdentifier(parentOrderedList)).withChild(createParentOrderedListEntry("pkval2", "plfval2"))
+                .build();
 
         ContainerNode parentContainerNode = Builders.containerBuilder().withNodeIdentifier(
                 new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
-                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build()).build();
+                .withNodeIdentifier(new NodeIdentifier(childContainer)).withChild(parentOrderedListNode).build())
+                .build();
 
         ContainerNode parentContainerNode2 = Builders.containerBuilder().withNodeIdentifier(
                 new NodeIdentifier(parentContainer)).withChild(Builders.containerBuilder()
@@ -281,27 +282,27 @@ public class OrderedListTest {
         assertFalse(readNode.isPresent());
     }
 
-    private MapEntryNode createParentOrderedListEntry(String keyValue, String leafValue) {
+    private MapEntryNode createParentOrderedListEntry(final String keyValue, final String leafValue) {
         return Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(parentOrderedList,
                 parentKeyLeaf, keyValue))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(parentOrdinaryLeaf)).withValue
-                        (leafValue).build()).build();
+                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(parentOrdinaryLeaf))
+                    .withValue(leafValue).build()).build();
     }
 
-    private MapEntryNode createChildOrderedListEntry(String keyValue, String leafValue) {
+    private MapEntryNode createChildOrderedListEntry(final String keyValue, final String leafValue) {
         return Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(childOrderedList,
                 childKeyLeaf, keyValue))
-                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(childOrdinaryLeaf)).withValue
-                        (leafValue).build()).build();
+                .withChild(Builders.leafBuilder().withNodeIdentifier(NodeIdentifier.create(childOrdinaryLeaf))
+                    .withValue(leafValue).build()).build();
     }
 
-    private NodeIdentifierWithPredicates createParentOrderedListEntryPath(String keyValue) {
+    private NodeIdentifierWithPredicates createParentOrderedListEntryPath(final String keyValue) {
         ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
         ImmutableMap<QName, Object> keys = builder.put(parentKeyLeaf, keyValue).build();
         return new NodeIdentifierWithPredicates(parentOrderedList, keys);
     }
 
-    private NodeIdentifierWithPredicates createChildOrderedListEntryPath(String keyValue) {
+    private NodeIdentifierWithPredicates createChildOrderedListEntryPath(final String keyValue) {
         ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builder();
         ImmutableMap<QName, Object> keys = builder.put(childKeyLeaf, keyValue).build();
         return new NodeIdentifierWithPredicates(childOrderedList, keys);
index df72495d98f0e266f5e2aa59f9bcec5d08fad39f..3dbe14d407be4645fdc5c4fe6aeb928155fa3d48 100644 (file)
@@ -24,8 +24,8 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNodes;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
@@ -43,24 +43,26 @@ public class StoreTreeNodesTest {
     private static final String TWO_ONE_NAME = "one";
     private static final String TWO_TWO_NAME = "two";
 
-    private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_1_PATH = YangInstanceIdentifier.builder(
+        TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, ONE_ID)
             .build();
 
-    private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
-            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
+    private static final YangInstanceIdentifier OUTER_LIST_2_PATH = YangInstanceIdentifier.builder(
+        TestModel.OUTER_LIST_PATH)
+            .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
             .build();
 
     private static final YangInstanceIdentifier TWO_TWO_PATH = YangInstanceIdentifier.builder(OUTER_LIST_2_PATH)
-            .node(TestModel.INNER_LIST_QNAME) //
-            .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME) //
+            .node(TestModel.INNER_LIST_QNAME)
+            .nodeWithKey(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)
             .build();
 
-    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID) //
-            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME) //
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME)) //
-                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME)) //
-                    .build()) //
+    private static final MapEntryNode BAR_NODE = mapEntryBuilder(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, TWO_ID)
+            .withChild(mapNodeBuilder(TestModel.INNER_LIST_QNAME)
+                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_ONE_NAME))
+                    .withChild(mapEntry(TestModel.INNER_LIST_QNAME, TestModel.NAME_QNAME, TWO_TWO_NAME))
+                    .build())
                     .build();
 
     private SchemaContext schemaContext;
@@ -70,7 +72,8 @@ public class StoreTreeNodesTest {
     public void prepare() throws ReactorException {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext, DataTreeConfiguration.DEFAULT_OPERATIONAL));
+        rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext,
+            DataTreeConfiguration.DEFAULT_OPERATIONAL));
     }
 
     public NormalizedNode<?, ?> createDocumentOne() {
@@ -156,7 +159,8 @@ public class StoreTreeNodesTest {
         final TreeNode rootNode = inMemoryDataTreeSnapshot.getRootNode();
         final Optional<TreeNode> expectedNode = StoreTreeNodes.findNode(rootNode, TWO_TWO_PATH);
         assertPresentAndType(expectedNode, TreeNode.class);
-        final Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = StoreTreeNodes.findClosest(rootNode, TWO_TWO_PATH);
+        final Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = StoreTreeNodes.findClosest(rootNode,
+            TWO_TWO_PATH);
         assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
     }
 
@@ -174,7 +178,8 @@ public class StoreTreeNodesTest {
                 .build();
         final Optional<TreeNode> expectedNode = StoreTreeNodes.findNode(rootNode, outerListInnerListPath);
         assertPresentAndType(expectedNode, TreeNode.class);
-        final Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = StoreTreeNodes.findClosest(rootNode, twoTwoInvalidPath);
+        final Map.Entry<YangInstanceIdentifier, TreeNode> actualNode = StoreTreeNodes.findClosest(rootNode,
+            twoTwoInvalidPath);
         assertEquals("Expected node and actual node are not the same", expectedNode.get(), actualNode.getValue());
     }
 
index b325136f3960e9d19015c7e469ac6131bbc7751b..cf2252b758175889ccb1b502bbd75ed2d753ca6a 100644 (file)
@@ -28,9 +28,9 @@ public class TestModel {
     public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
     public static final YangInstanceIdentifier OUTER_LIST_PATH = YangInstanceIdentifier.builder(TEST_PATH)
             .node(OUTER_LIST_QNAME).build();
-    public static final YangInstanceIdentifier INNER_CONTAINER_PATH = YangInstanceIdentifier.builder(TEST_PATH).node(INNER_CONTAINER_QNAME).build();
+    public static final YangInstanceIdentifier INNER_CONTAINER_PATH = TEST_PATH.node(INNER_CONTAINER_QNAME);
     public static final YangInstanceIdentifier VALUE_PATH = YangInstanceIdentifier.of(VALUE_QNAME);
-    public static final YangInstanceIdentifier INNER_VALUE_PATH = YangInstanceIdentifier.builder(INNER_CONTAINER_PATH).node(VALUE_QNAME).build();
+    public static final YangInstanceIdentifier INNER_VALUE_PATH = INNER_CONTAINER_PATH.node(VALUE_QNAME);
     public static final QName TWO_QNAME = QName.create(TEST_QNAME, "two");
     public static final QName THREE_QNAME = QName.create(TEST_QNAME, "three");