BUG-272: cleanup sal-rest-connector
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / DummyRpcResult.java
1 /*
2  * Copyright (c) 2014 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.restconf.impl.test;
9
10 import java.util.Collection;
11
12 import org.opendaylight.yangtools.yang.common.RpcError;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14
15 public class DummyRpcResult<T> implements RpcResult<T> {
16
17     private final boolean isSuccessful;
18     private final T result;
19     private final Collection<RpcError> errors;
20
21     public DummyRpcResult() {
22         isSuccessful = false;
23         result = null;
24         errors = null;
25     }
26
27     private DummyRpcResult(final Builder<T> builder) {
28         isSuccessful = builder.isSuccessful;
29         result = builder.result;
30         errors = builder.errors;
31     }
32
33     @Override
34     public boolean isSuccessful() {
35         return isSuccessful;
36     }
37
38     @Override
39     public T getResult() {
40         return result;
41     }
42
43     @Override
44     public Collection<RpcError> getErrors() {
45         return errors;
46     }
47
48     public static class Builder<T> {
49         private boolean isSuccessful;
50         private T result;
51         private Collection<RpcError> errors;
52
53         public Builder<T> isSuccessful(final boolean isSuccessful) {
54             this.isSuccessful = isSuccessful;
55             return this;
56         }
57
58         public Builder<T> result(final T result) {
59             this.result = result;
60             return this;
61         }
62
63         public Builder<T> errors(final Collection<RpcError> errors) {
64             this.errors = errors;
65             return this;
66         }
67
68         public RpcResult<T> build() {
69             return new DummyRpcResult<T>(this);
70         }
71
72     }
73
74 }