Merge "Fixed for bug 1168 : Issue while update subnet"
[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 import org.opendaylight.yangtools.yang.common.RpcError;
12 import org.opendaylight.yangtools.yang.common.RpcResult;
13
14 public class DummyRpcResult<T> implements RpcResult<T> {
15
16     private final boolean isSuccessful;
17     private final T result;
18     private final Collection<RpcError> errors;
19
20     public DummyRpcResult() {
21         isSuccessful = false;
22         result = null;
23         errors = null;
24     }
25
26     private DummyRpcResult(final Builder<T> builder) {
27         isSuccessful = builder.isSuccessful;
28         result = builder.result;
29         errors = builder.errors;
30     }
31
32     @Override
33     public boolean isSuccessful() {
34         return isSuccessful;
35     }
36
37     @Override
38     public T getResult() {
39         return result;
40     }
41
42     @Override
43     public Collection<RpcError> getErrors() {
44         return errors;
45     }
46
47     public static class Builder<T> {
48         private boolean isSuccessful;
49         private T result;
50         private Collection<RpcError> errors;
51
52         public Builder<T> isSuccessful(final boolean isSuccessful) {
53             this.isSuccessful = isSuccessful;
54             return this;
55         }
56
57         public Builder<T> result(final T result) {
58             this.result = result;
59             return this;
60         }
61
62         public Builder<T> errors(final Collection<RpcError> errors) {
63             this.errors = errors;
64             return this;
65         }
66
67         public RpcResult<T> build() {
68             return new DummyRpcResult<T>(this);
69         }
70
71     }
72
73 }