2 * Copyright (c) 2013 Cisco Systems, Inc. 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.controller.sal.common.util;
10 import com.google.common.collect.ImmutableList;
11 import java.io.Serializable;
12 import java.util.Collection;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.yang.common.RpcError;
15 import org.opendaylight.yangtools.yang.common.RpcResult;
20 * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
23 public final class Rpcs {
27 public static <T> RpcResult<T> getRpcResult(boolean successful) {
28 return new RpcResultTO<>(successful, null, ImmutableList.of());
31 public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
32 Collection<RpcError> errors) {
33 return new RpcResultTO<>(successful, result, errors);
36 public static <T> RpcResult<T> getRpcResult(boolean successful, Collection<RpcError> errors) {
37 return new RpcResultTO<>(successful, null, errors);
40 private static class RpcResultTO<T> implements RpcResult<T>, Serializable, Immutable {
41 private static final long serialVersionUID = 1L;
42 private final Collection<RpcError> errors;
43 private final T result;
44 private final boolean successful;
46 RpcResultTO(boolean successful, T result, Collection<RpcError> errors) {
47 this.successful = successful;
49 this.errors = ImmutableList.copyOf(errors);
53 public boolean isSuccessful() {
58 public T getResult() {
63 public Collection<RpcError> getErrors() {