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 java.io.Serializable;
11 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;
17 import com.google.common.collect.ImmutableList;
20 * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
25 public static <T> RpcResult<T> getRpcResult(boolean successful) {
26 return new RpcResultTO<>(successful, null, ImmutableList.of());
29 public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
30 Collection<RpcError> errors) {
31 return new RpcResultTO<>(successful, result, errors);
34 public static <T> RpcResult<T> getRpcResult(boolean successful, Collection<RpcError> errors) {
35 return new RpcResultTO<>(successful, null, errors);
38 private static class RpcResultTO<T> implements RpcResult<T>, Serializable, Immutable {
39 private static final long serialVersionUID = 1L;
40 private final Collection<RpcError> errors;
41 private final T result;
42 private final boolean successful;
44 public RpcResultTO(boolean successful, T result,
45 Collection<RpcError> errors) {
46 this.successful = successful;
48 this.errors = ImmutableList.copyOf(errors);
52 public boolean isSuccessful() {
57 public T getResult() {
62 public Collection<RpcError> getErrors() {