Fix for radio buttons
[sdc.git] / asdc-tests / src / main / java / org / openecomp / sdc / ci / tests / datatypes / enums / ErrorInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.ci.tests.datatypes.enums;
22
23 public class ErrorInfo {
24
25         private Integer code;
26         private String message;
27         private String messageId;
28
29         public ErrorInfo() {
30                 super();
31                 // TODO Auto-generated constructor stub
32         }
33
34         public ErrorInfo(Integer code, String message, String messageId) {
35                 super();
36                 this.code = code;
37                 this.message = message;
38                 this.messageId = messageId;
39         }
40
41         public ErrorInfo(Integer code, String message) {
42                 super();
43                 this.code = code;
44                 this.message = message;
45         }
46
47         public Integer getCode() {
48                 return code;
49         }
50
51         public void setCode(Integer code) {
52                 this.code = code;
53         }
54
55         public String getMessage() {
56                 return message;
57         }
58
59         public String getMessageAndReplaceVariables(Object... variables) {
60                 String formatReadyString = message.replaceAll("%[\\d]+", "%s");
61                 formatReadyString = String.format(formatReadyString, variables);
62                 return formatReadyString;
63         }
64
65         public String getAuditDesc(Object... variables) {
66                 String messageAndReplaceVariables = getMessageAndReplaceVariables(variables);
67                 String res;
68                 if (messageId != null) {
69                         res = messageId + ": " + messageAndReplaceVariables;
70                 } else {
71                         res = messageAndReplaceVariables;
72                 }
73                 return res;
74         }
75
76         public void setMessage(String message) {
77                 this.message = message;
78         }
79
80         public String getMessageId() {
81                 return messageId;
82         }
83
84         public void setMessageId(String messageId) {
85                 this.messageId = messageId;
86         }
87
88         @Override
89         public String toString() {
90                 return "ErrorInfo [code=" + code + ", message=" + message + ", messageId=" + messageId + "]";
91         }
92
93 }