Switch to Objects.requireNonNull
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / impl / context / base / LazyTreeNode.java
index 288622ebabc287555841d7b0268dac3f91d19621..ef7d8133d6ff9551db0b1d1ea7e58383cdf3d188 100644 (file)
@@ -8,10 +8,11 @@
 
 package org.opendaylight.mdsal.binding.javav2.dom.codec.impl.context.base;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import java.lang.reflect.InvocationHandler;
@@ -21,6 +22,7 @@ import java.lang.reflect.Proxy;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import org.opendaylight.mdsal.binding.javav2.dom.codec.api.AugmentationReader;
 import org.opendaylight.mdsal.binding.javav2.runtime.reflection.BindingReflections;
@@ -54,8 +56,8 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
     LazyTreeNode(final TreeNodeCodecContext<D,?> ctx, final NormalizedNodeContainer data) {
-        this.context = Preconditions.checkNotNull(ctx, "Context must not be null");
-        this.data = Preconditions.checkNotNull(data, "Data must not be null");
+        this.context = requireNonNull(ctx, "Context must not be null");
+        this.data = requireNonNull(data, "Data must not be null");
     }
 
     @Override
@@ -99,7 +101,7 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
                     if (!Arrays.equals((byte[]) thisValue, (byte[]) otherValue)) {
                         return false;
                     }
-                } else if (!Objects.equals(thisValue, otherValue)){
+                } else if (!Objects.equals(thisValue, otherValue)) {
                     return false;
                 }
             }
@@ -119,7 +121,7 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
     private static Map<Class<? extends Augmentation<?>>, Augmentation<?>> getAllAugmentations(final Object dataObject) {
         if (dataObject instanceof AugmentationReader) {
             return ((AugmentationReader) dataObject).getAugmentations(dataObject);
-        } else if (dataObject instanceof Augmentable<?>){
+        } else if (dataObject instanceof Augmentable<?>) {
             return BindingReflections.getAugmentations((Augmentable<?>) dataObject);
         }
 
@@ -139,7 +141,7 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
             result = prime * result + Objects.hashCode(value);
         }
         if (Augmentable.class.isAssignableFrom(context.getBindingClass())) {
-            result = prime * result + (getAugmentationsImpl().hashCode());
+            result = prime * result + getAugmentationsImpl().hashCode();
         }
         cachedHashcode = result;
         return result;
@@ -188,11 +190,11 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
         if (aug != null) {
             return aug.get(cls);
         }
-        Preconditions.checkNotNull(cls,"Supplied augmentation must not be null.");
+        requireNonNull(cls,"Supplied augmentation must not be null.");
 
         @SuppressWarnings({"unchecked","rawtypes"})
-        final Optional<DataContainerCodecContext<?,?>> augCtx= context.possibleStreamChild((Class) cls);
-        if(augCtx.isPresent()) {
+        final Optional<DataContainerCodecContext<?,?>> augCtx = context.possibleStreamChild((Class) cls);
+        if (augCtx.isPresent()) {
             final Optional<NormalizedNode<?, ?>> augData = data.getChild(augCtx.get().getDomPathArgument());
             if (augData.isPresent()) {
                 return augCtx.get().deserialize(augData.get());
@@ -232,4 +234,4 @@ class LazyTreeNode<D extends TreeNode> implements InvocationHandler, Augmentatio
         final LazyTreeNode<?> other = (LazyTreeNode<?>) obj;
         return Objects.equals(context, other.context) && Objects.equals(data, other.data);
     }
-}
\ No newline at end of file
+}