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