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 lombok.AllArgsConstructor;
23 public enum ComponentTypeEnum {
26 RESOURCE_INSTANCE("Resource Instance"),
28 SERVICE_INSTANCE("Service Instance");
30 // Those values cannot be another field in enum, because they are needed
31 // as constants for Swagger allowedValues param
32 public static final String RESOURCE_PARAM_NAME = "resources";
33 public static final String SERVICE_PARAM_NAME = "services";
34 public static final String PRODUCT_PARAM_NAME = "products";
35 private final String value;
37 public static ComponentTypeEnum findByValue(String value) {
38 ComponentTypeEnum ret = null;
39 for (ComponentTypeEnum curr : ComponentTypeEnum.values()) {
40 if (curr.getValue().equals(value)) {
48 public static ComponentTypeEnum findByParamName(String paramName) {
49 ComponentTypeEnum ret = null;
51 case RESOURCE_PARAM_NAME:
54 case SERVICE_PARAM_NAME:
57 case PRODUCT_PARAM_NAME:
66 public static String findParamByType(ComponentTypeEnum type) {
74 ret = RESOURCE_PARAM_NAME;
77 ret = SERVICE_PARAM_NAME;
80 ret = PRODUCT_PARAM_NAME;
88 public NodeTypeEnum getNodeType() {
92 return NodeTypeEnum.Resource;
94 return NodeTypeEnum.Service;
96 return NodeTypeEnum.Product;
97 case RESOURCE_INSTANCE:
98 return NodeTypeEnum.ResourceInstance;
100 throw new UnsupportedOperationException("No nodeType is defined for: " + this.getValue());