Fix modernization issues
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / RpcServiceAdapter.java
index a9b1cc5cc49c08313e828b7c4f2758dd61710e25..af2ad1dc5baea14cbd7dc064ba6aa42fafbff067 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
@@ -45,6 +46,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
+@Deprecated
 class RpcServiceAdapter implements InvocationHandler {
 
     private final ImmutableMap<Method, RpcInvocationStrategy> rpcNames;
@@ -55,9 +57,9 @@ class RpcServiceAdapter implements InvocationHandler {
 
     RpcServiceAdapter(final Class<? extends RpcService> type, final BindingToNormalizedNodeCodec codec,
             final DOMRpcService domService) {
-        this.type = Preconditions.checkNotNull(type);
-        this.codec = Preconditions.checkNotNull(codec);
-        this.delegate = Preconditions.checkNotNull(domService);
+        this.type = requireNonNull(type);
+        this.codec = requireNonNull(codec);
+        this.delegate = requireNonNull(domService);
         final ImmutableMap.Builder<Method, RpcInvocationStrategy> rpcBuilder = ImmutableMap.builder();
         for (final Entry<Method, RpcDefinition> rpc : codec.getRpcMethodToSchema(type).entrySet()) {
             rpcBuilder.put(rpc.getKey(), createStrategy(rpc.getKey(), rpc.getValue()));
@@ -98,7 +100,7 @@ class RpcServiceAdapter implements InvocationHandler {
 
         final RpcInvocationStrategy rpc = rpcNames.get(method);
         if (rpc != null) {
-            if (method.getParameterTypes().length == 0) {
+            if (method.getParameterCount() == 0) {
                 return rpc.invokeEmpty();
             }
             if (args.length != 1) {
@@ -116,11 +118,11 @@ class RpcServiceAdapter implements InvocationHandler {
     private static boolean isObjectMethod(final Method method) {
         switch (method.getName()) {
             case "toString":
-                return method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0;
+                return method.getReturnType().equals(String.class) && method.getParameterCount() == 0;
             case "hashCode":
-                return method.getReturnType().equals(int.class) && method.getParameterTypes().length == 0;
+                return method.getReturnType().equals(int.class) && method.getParameterCount() == 0;
             case "equals":
-                return method.getReturnType().equals(boolean.class) && method.getParameterTypes().length == 1 && method
+                return method.getReturnType().equals(boolean.class) && method.getParameterCount() == 1 && method
                         .getParameterTypes()[0] == Object.class;
             default:
                 return false;