Devices dashlet show port total numbers, modal shows collapsible list
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / Rpcs.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.sal.common.util;\r
9 \r
10 import java.util.ArrayList;\r
11 import java.util.Collection;\r
12 import java.util.Collections;\r
13 import org.opendaylight.controller.yang.common.RpcError;\r
14 import org.opendaylight.controller.yang.common.RpcResult;\r
15 \r
16 public class Rpcs {\r
17     public static <T> RpcResult<T> getRpcResult(boolean successful, T result,\r
18             Collection<RpcError> errors) {\r
19         RpcResult<T> ret = new RpcResultTO<T>(successful, result, errors);\r
20         return ret;\r
21     }\r
22 \r
23     private static class RpcResultTO<T> implements RpcResult<T> {\r
24 \r
25         private final Collection<RpcError> errors;\r
26         private final T result;\r
27         private final boolean successful;\r
28 \r
29         public RpcResultTO(boolean successful, T result,\r
30                 Collection<RpcError> errors) {\r
31             this.successful = successful;\r
32             this.result = result;\r
33             this.errors = Collections.unmodifiableList(new ArrayList<RpcError>(\r
34                     errors));\r
35         }\r
36 \r
37         @Override\r
38         public boolean isSuccessful() {\r
39             return successful;\r
40         }\r
41 \r
42         @Override\r
43         public T getResult() {\r
44             return result;\r
45         }\r
46 \r
47         @Override\r
48         public Collection<RpcError> getErrors() {\r
49             return errors;\r
50         }\r
51 \r
52     }\r
53 }\r