*/
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;
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()));
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) {
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];
}
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();
}