Improve test coverage
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / ExternalCategoryTypeEnum.java
1 /*-
2  * Copyright (C) 2019 Telstra Intellectual Property. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package org.openecomp.sdc.be.datatypes.enums;
17
18 import lombok.AllArgsConstructor;
19 import lombok.Getter;
20
21 /**
22  * Category Type Enum Any service category to be supported by SDC Ext API can be added here
23  *
24  * @author atifhusain
25  */
26 @Getter
27 @AllArgsConstructor
28 public enum ExternalCategoryTypeEnum {
29
30     PARTNER_DOMAIN_SERVICE("Partner Domain Service", true);
31
32     private final String value;
33     private final boolean isAtomicType;
34
35     public static ExternalCategoryTypeEnum getType(String type) {
36         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
37             if (e.name().equals(type)) {
38                 return e;
39             }
40         }
41         return null;
42     }
43
44     public static ExternalCategoryTypeEnum getTypeByName(String type) {
45         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
46             if (e.getValue().equalsIgnoreCase(type)) {
47                 return e;
48             }
49         }
50         return null;
51     }
52
53     /**
54      * Returns CategoryTypeEnum matching to received String ignore case
55      *
56      * @param type
57      * @return
58      */
59     public static ExternalCategoryTypeEnum getTypeIgnoreCase(String type) {
60         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
61             if (e.getValue().equalsIgnoreCase(type)) {
62                 return e;
63             }
64         }
65         return null;
66     }
67
68     /**
69      * Checks if enum exist with given type
70      *
71      * @param type
72      * @return
73      */
74     public static boolean containsName(String type) {
75
76         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
77             if (e.getValue().equals(type)) {
78                 return true;
79             }
80         }
81         return false;
82     }
83
84     /**
85      * Checks if enum exist with given type ignore case
86      *
87      * @param type
88      * @return
89      */
90     public static boolean containsIgnoreCase(String type) {
91
92         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
93             if (e.getValue().equalsIgnoreCase(type)) {
94                 return true;
95             }
96         }
97         return false;
98     }
99
100 }
101