cacb167f6f54f962c4f7bb49b39452ed140186e1
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / RpcErrors.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 org.opendaylight.yangtools.yang.common.RpcError;
11 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
12 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
13
14 /**
15  * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
16  */
17 @Deprecated
18 public class RpcErrors {
19
20     /**
21      * @param applicationTag
22      * @param tag
23      * @param info
24      * @param severity
25      * @param message
26      * @param errorType
27      * @param cause
28      * @return {@link RpcError} implementation
29      */
30     public static RpcError getRpcError(String applicationTag, String tag, String info,
31             ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
32         RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message,
33                 errorType, cause);
34         return ret;
35     }
36
37     private static class RpcErrorTO implements RpcError {
38
39         private final String applicationTag;
40         private final String tag;
41         private final String info;
42         private final ErrorSeverity severity;
43         private final String message;
44         private final ErrorType errorType;
45         private final Throwable cause;
46
47         /**
48          * @param applicationTag
49          * @param tag
50          * @param info
51          * @param severity
52          * @param message
53          * @param errorType
54          * @param cause
55          */
56         protected RpcErrorTO(String applicationTag, String tag, String info,
57                 ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
58             super();
59             this.applicationTag = applicationTag;
60             this.tag = tag;
61             this.info = info;
62             this.severity = severity;
63             this.message = message;
64             this.errorType = errorType;
65             this.cause = cause;
66         }
67
68         @Override
69         public String getApplicationTag() {
70             return applicationTag;
71         }
72
73         @Override
74         public String getInfo() {
75             return info;
76         }
77
78         @Override
79         public String getMessage() {
80             return message;
81         }
82
83         @Override
84         public ErrorSeverity getSeverity() {
85             return severity;
86         }
87
88         @Override
89         public String getTag() {
90             return tag;
91         }
92
93         @Override
94         public Throwable getCause() {
95             return cause;
96         }
97
98         @Override
99         public ErrorType getErrorType() {
100             return errorType;
101         }
102     }
103 }