2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.binding.dom.adapter;
10 import java.util.Collection;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
14 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
15 import org.opendaylight.yangtools.yang.common.RpcError;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
20 * Utility methods for converting {@link RpcResult} to/from {@link DOMRpcResult}.
23 final class RpcResultUtil {
24 private RpcResultUtil() {
29 * DOMRpcResult does not have a notion of success, hence we have to reverse-engineer it by looking at reported
30 * errors and checking whether they are just warnings.
32 static <T> RpcResult<T> rpcResultFromDOM(final Collection<? extends RpcError> errors, final @Nullable T result) {
33 return RpcResultBuilder.<T>status(errors.stream().noneMatch(err -> err.getSeverity() == ErrorSeverity.ERROR))
35 .withRpcErrors(errors)