Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-common / src / main / java / org / openecomp / dcae / apod / analytics / common / validation / ValidationResponse.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.common.validation;\r
22 \r
23 import java.util.Collection;\r
24 import java.util.Map;\r
25 import java.util.Set;\r
26 \r
27 /**\r
28  * Validation Response contract\r
29  *\r
30  * @param <T> Entity class type which is being validated\r
31  *\r
32  * @author Rajiv Singla . Creation Date: 10/24/2016.\r
33  */\r
34 public interface ValidationResponse<T> {\r
35 \r
36     /**\r
37      * Returns true if validation resulted in one or more errors\r
38      *\r
39      * @return true if validation has errors\r
40      */\r
41     boolean hasErrors();\r
42 \r
43     /**\r
44      * Returns all field names which have error\r
45      *\r
46      * @return names of fields which have error\r
47      */\r
48     Set<String> getFieldNamesWithError();\r
49 \r
50     /**\r
51      * Returns list of all error messages\r
52      *\r
53      * @return list of error messages\r
54      */\r
55     Collection<String> getErrorMessages();\r
56 \r
57 \r
58     /**\r
59      * Returns all error messages as string delimited by comma\r
60      *\r
61      * @return all error messages delimited by given delimiter\r
62      */\r
63     String getAllErrorMessage();\r
64 \r
65     /**\r
66      * Returns all error messages as string delimited by given delimited\r
67      *\r
68      * @param delimiter delimited to be used for error message\r
69      * @return all error messages delimited by given delimiter\r
70      */\r
71     String getAllErrorMessage(String delimiter);\r
72 \r
73     /**\r
74      * Adds field name and error message to the validation response\r
75      *\r
76      * @param fieldName field name which has validation error\r
77      * @param filedErrorMessage validation error message\r
78      */\r
79     void addErrorMessage(String fieldName, String filedErrorMessage);\r
80 \r
81 \r
82     /**\r
83      * Returns validation results as map containing values as keys and values\r
84      * as error Message\r
85      *\r
86      * @return Map containing field names and error message associated with those fields\r
87      */\r
88     Map<String, String> getValidationResultsAsMap();\r
89 \r
90 }\r