Backend support for operation milestones with activities
[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 package org.openecomp.sdc.be.datatypes.enums;
16
17 import lombok.AllArgsConstructor;
18 import lombok.Getter;
19
20 /**
21  * Category Type Enum Any service category to be supported by SDC Ext API can be added here
22  *
23  * @author atifhusain
24  */
25 @Getter
26 @AllArgsConstructor
27 public enum ExternalCategoryTypeEnum {
28     PARTNER_DOMAIN_SERVICE("Partner Domain Service", true);
29     private final String value;
30     private final boolean isAtomicType;
31
32     public static ExternalCategoryTypeEnum getType(String type) {
33         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
34             if (e.name().equals(type)) {
35                 return e;
36             }
37         }
38         return null;
39     }
40
41     public static ExternalCategoryTypeEnum getTypeByName(String type) {
42         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
43             if (e.getValue().equalsIgnoreCase(type)) {
44                 return e;
45             }
46         }
47         return null;
48     }
49
50     /**
51      * Returns CategoryTypeEnum matching to received String ignore case
52      *
53      * @param type
54      * @return
55      */
56     public static ExternalCategoryTypeEnum getTypeIgnoreCase(String type) {
57         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
58             if (e.getValue().equalsIgnoreCase(type)) {
59                 return e;
60             }
61         }
62         return null;
63     }
64
65     /**
66      * Checks if enum exist with given type
67      *
68      * @param type
69      * @return
70      */
71     public static boolean containsName(String type) {
72         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
73             if (e.getValue().equals(type)) {
74                 return true;
75             }
76         }
77         return false;
78     }
79
80     /**
81      * Checks if enum exist with given type ignore case
82      *
83      * @param type
84      * @return
85      */
86     public static boolean containsIgnoreCase(String type) {
87         for (ExternalCategoryTypeEnum e : ExternalCategoryTypeEnum.values()) {
88             if (e.getValue().equalsIgnoreCase(type)) {
89                 return true;
90             }
91         }
92         return false;
93     }
94 }