use of org.opendaylight.yangtools.yang.binding.RpcInput in project mdsal by opendaylight.
the class ActionAdapter method invoke.
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws NoSuchMethodError {
switch(method.getName()) {
case "equals":
if (args.length == 1) {
return proxy == args[0];
}
break;
case "hashCode":
if (args.length == 0) {
return System.identityHashCode(proxy);
}
break;
case "toString":
if (args.length == 0) {
return spec.type().getName() + "$Adapter{delegate=" + getDelegate() + "}";
}
break;
case "invoke":
if (args.length == 2) {
final InstanceIdentifier<?> path = (InstanceIdentifier<?>) requireNonNull(args[0]);
checkArgument(!path.isWildcarded(), "Cannot invoke action on wildcard path %s", path);
final RpcInput input = (RpcInput) requireNonNull(args[1]);
final CurrentAdapterSerializer serializer = currentSerializer();
final ListenableFuture<? extends DOMActionResult> future = getDelegate().invokeAction(actionPath, new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, serializer.toYangInstanceIdentifier(path)), serializer.toLazyNormalizedNodeActionInput(spec.type(), inputName, input));
// Invocation returned a future we know about -- return that future instead
if (ENABLE_CODEC_SHORTCUT && future instanceof BindingRpcFutureAware) {
return ((BindingRpcFutureAware) future).getBindingFuture();
}
return Futures.transform(future, dom -> RpcResultUtil.rpcResultFromDOM(dom.getErrors(), dom.getOutput().map(output -> serializer.fromNormalizedNodeActionOutput(spec.type(), output)).orElse(null)), MoreExecutors.directExecutor());
}
break;
default:
break;
}
throw new NoSuchMethodError("Method " + method.toString() + "is unsupported.");
}
Aggregations