Imp Modules refactored for the readthedocs
[so.git] / adapters / mso-vfc-adapter / src / main / java / org / openecomp / mso / adapters / vfc / util / ValidateUtil.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP - SO\r
4  * ================================================================================\r
5  * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.mso.adapters.vfc.util;\r
22 \r
23 import org.openecomp.mso.adapters.vfc.constant.HttpCode;\r
24 import org.openecomp.mso.adapters.vfc.exceptions.ApplicationException;\r
25 import org.slf4j.Logger;\r
26 import org.slf4j.LoggerFactory;\r
27 \r
28 public class ValidateUtil {\r
29 \r
30   /**\r
31    * Log server.\r
32    */\r
33   private static final Logger LOGGER = LoggerFactory.getLogger(ValidateUtil.class);\r
34 \r
35   /**\r
36    * Constructor<br/>\r
37    * <p>\r
38    * </p>\r
39    * \r
40    * @since ONAP Amsterdam Release 2017-9-6\r
41    */\r
42   private ValidateUtil() {\r
43 \r
44   }\r
45 \r
46   /**\r
47    * Assert String parameter.<br/>\r
48    * \r
49    * @param paramValue parameter data\r
50    * @param name of parameter\r
51    * @since ONAP Amsterdam Release 2017-9-6\r
52    */\r
53   public static void assertStringNotNull(String paramValue, String paramName)\r
54       throws ApplicationException {\r
55     if (null != paramValue && !paramValue.isEmpty()) {\r
56       return;\r
57     }\r
58 \r
59     LOGGER.error(paramName + ": Parameter is null or empty.");\r
60     throw new ApplicationException(HttpCode.BAD_REQUEST, paramName + ": Invalid parameter.");\r
61   }\r
62 \r
63   /**\r
64    * Assert object is null.<br/>\r
65    * \r
66    * @param object data object\r
67    * @since ONAP Amsterdam Release 2017-9-6\r
68    */\r
69   public static void assertObjectNotNull(Object object) throws ApplicationException {\r
70     if (null == object) {\r
71       LOGGER.error("Object is null.");\r
72       throw new ApplicationException(HttpCode.BAD_REQUEST, "Object is null.");\r
73     }\r
74 \r
75   }\r
76 \r
77   /**\r
78    * <br>\r
79    * \r
80    * @param str\r
81    * @return\r
82    * @since ONAP Amsterdam Release\r
83    */\r
84   public static boolean isStrEmpty(String str) {\r
85     return null == str || str.isEmpty();\r
86   }\r
87 }\r