Remove use of YangInstanceIdentifier.EMPTY
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / RpcServiceAdapter.java
index ef1379d13205bb8626c9e3afb30fcb5b92467f54..1938faf875ae2c86c8e30b6b3f0eaf3278139d43 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.mdsal.binding.dom.adapter;
 
+import static java.util.Objects.requireNonNull;
+import static org.opendaylight.mdsal.binding.dom.adapter.StaticConfiguration.ENABLE_CODEC_SHORTCUT;
+
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Futures;
@@ -47,9 +50,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()));
@@ -76,7 +79,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) {
@@ -87,17 +90,17 @@ class RpcServiceAdapter implements InvocationHandler {
 
         switch (method.getName()) {
             case "toString":
-                if (method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0) {
+                if (method.getReturnType().equals(String.class) && method.getParameterCount() == 0) {
                     return type.getName() + "$Adapter{delegate=" + delegate.toString() + "}";
                 }
                 break;
             case "hashCode":
-                if (method.getReturnType().equals(int.class) && method.getParameterTypes().length == 0) {
+                if (method.getReturnType().equals(int.class) && method.getParameterCount() == 0) {
                     return System.identityHashCode(proxy);
                 }
                 break;
             case "equals":
-                if (method.getReturnType().equals(boolean.class) && method.getParameterTypes().length == 1
+                if (method.getReturnType().equals(boolean.class) && method.getParameterCount() == 1
                         && method.getParameterTypes()[0] == Object.class) {
                     return proxy == args[0];
                 }
@@ -133,7 +136,7 @@ class RpcServiceAdapter implements InvocationHandler {
 
         ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final ContainerNode input) {
             final ListenableFuture<DOMRpcResult> result = delegate.invokeRpc(schemaPath, input);
-            if (result instanceof BindingRpcFutureAware) {
+            if (ENABLE_CODEC_SHORTCUT && result instanceof BindingRpcFutureAware) {
                 return ((BindingRpcFutureAware) result).getBindingFuture();
             }