2 * Copyright (C) 2017 AT&T 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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.openecomp.sdc.be.datatypes.enums;
18 import java.util.Arrays;
25 public enum ResourceTypeEnum {
27 VFC("VFC"/* (Virtual Function Component)"*/, true),
28 VF("VF"/* (Virtual Function)" */, false),
29 CR("CR"/* (Complex Resource"*/, false),
30 CP("CP"/* (Connection Point)"*/, true),
31 PNF("PNF"/* (Physical Network Function)" */, false),
32 CVFC("CVFC"/* Complex Virtual Function Component*/, false),
33 VL("VL"/* (Virtual Link)"*/, true),
34 VFCMT("VFCMT"/* (VFC Monitoring Template)"*/, true),
35 Configuration("Configuration", true),
36 ServiceProxy("ServiceProxy", true),
37 //Generic VFC/VF/PNF/Service Type
38 ABSTRACT("Abstract", true);
40 private final String value;
41 private final boolean isAtomicType;
43 ResourceTypeEnum(final String value, final boolean isAtomicType) {
45 this.isAtomicType = isAtomicType;
48 public String getValue() {
52 public boolean isAtomicType() {
56 public static ResourceTypeEnum getType(final String type) {
60 return Arrays.stream(ResourceTypeEnum.values())
61 .filter(resourceTypeEnum -> resourceTypeEnum.name().equals(type))
66 public static ResourceTypeEnum getTypeByName(final String type) {
70 return Arrays.stream(ResourceTypeEnum.values())
71 .filter(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type))
77 * Returns ResourceTypeEnum matching to received String ignore case
79 * @param type the resource type
80 * @return the resource type as a enum if found, {@code null} otherwise
82 public static ResourceTypeEnum getTypeIgnoreCase(final String type) {
86 return Arrays.stream(ResourceTypeEnum.values())
87 .filter(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type))
93 * Checks if enum exist with given type
95 * @param type the resource type
96 * @return {@code true} if the given resource type exists, {@code false} otherwise
98 public static boolean containsName(final String type) {
102 return Arrays.stream(ResourceTypeEnum.values())
103 .anyMatch(resourceTypeEnum -> resourceTypeEnum.name().equals(type));
107 * Checks if enum exist with given type ignore case
109 * @param type the resource type
110 * @return {@code true} if the type exists, {@code false} otherwise
112 public static boolean containsIgnoreCase(final String type) {
116 return Arrays.stream(ResourceTypeEnum.values())
117 .anyMatch(resourceTypeEnum -> resourceTypeEnum.name().equalsIgnoreCase(type));