Deprecate Broker and related APIs
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / Rpcs.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.common.util;
9
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.RpcError;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
15
16 /**
17  * Deprecated.
18  *
19  * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
20  */
21 @Deprecated
22 public final class Rpcs {
23     private Rpcs() {
24     }
25
26     public static <T> RpcResult<T> getRpcResult(boolean successful) {
27         return new RpcResultTO<>(successful, null, ImmutableList.of());
28     }
29
30     public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
31             Collection<RpcError> errors) {
32         return new RpcResultTO<>(successful, result, errors);
33     }
34
35     public static <T> RpcResult<T> getRpcResult(boolean successful, Collection<RpcError> errors) {
36         return new RpcResultTO<>(successful, null, errors);
37     }
38
39     private static class RpcResultTO<T> implements RpcResult<T>, Immutable {
40         private final Collection<RpcError> errors;
41         private final T result;
42         private final boolean successful;
43
44         RpcResultTO(boolean successful, T result, Collection<RpcError> errors) {
45             this.successful = successful;
46             this.result = result;
47             this.errors = ImmutableList.copyOf(errors);
48         }
49
50         @Override
51         public boolean isSuccessful() {
52             return successful;
53         }
54
55         @Override
56         public T getResult() {
57             return result;
58         }
59
60         @Override
61         public Collection<RpcError> getErrors() {
62             return errors;
63         }
64     }
65 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.