Use lambdas instead of anonymous classes
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / ModifiedNode.java
index 49a7873ac7b27e3290b20b0bdb82b5abf8b81b65..35da5d3650a4c87987b46679acb1625461e5c880 100644 (file)
@@ -27,8 +27,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  * Node Modification Node and Tree
  *
  * 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)} and {@link TreeNode} which represents original
- * state as tracked by {@link #getOriginal()}.
+ * lazily created and populated via {@link #modifyChild(PathArgument, ModificationApplyOperation, Version)} and
+ * {@link TreeNode} which represents original state as tracked by {@link #getOriginal()}.
  *
  * 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
@@ -37,11 +37,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  */
 @NotThreadSafe
 final class ModifiedNode extends NodeModification implements StoreTreeNode<ModifiedNode> {
-    static final Predicate<ModifiedNode> IS_TERMINAL_PREDICATE = new Predicate<ModifiedNode>() {
-        @Override
-        public boolean apply(@Nonnull final ModifiedNode input) {
-            Preconditions.checkNotNull(input);
-            switch (input.getOperation()) {
+    static final Predicate<ModifiedNode> IS_TERMINAL_PREDICATE = input -> {
+        Preconditions.checkNotNull(input);
+        switch (input.getOperation()) {
             case DELETE:
             case MERGE:
             case WRITE:
@@ -49,10 +47,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
             case TOUCH:
             case NONE:
                 return false;
-            }
-
-            throw new IllegalArgumentException(String.format("Unhandled modification type %s", input.getOperation()));
         }
+
+        throw new IllegalArgumentException(String.format("Unhandled modification type %s", input.getOperation()));
     };
 
     private final Map<PathArgument, ModifiedNode> children;
@@ -114,11 +111,11 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
      */
     @Override
     public Optional<ModifiedNode> getChild(final PathArgument child) {
-        return Optional.<ModifiedNode> fromNullable(children.get(child));
+        return Optional.fromNullable(children.get(child));
     }
 
     private Optional<TreeNode> metadataFromSnapshot(@Nonnull final PathArgument child) {
-        return original.isPresent() ? original.get().getChild(child) : Optional.<TreeNode>absent();
+        return original.isPresent() ? original.get().getChild(child) : Optional.absent();
     }
 
     private Optional<TreeNode> metadataFromData(@Nonnull final PathArgument child, final Version modVersion) {