blob: bbe0ed5442cbce83d17297204cf0697bcbedc9a0 [file] [log] [blame]
Aharoni, Pavel (pa0916)ca3cb012018-10-22 15:29:57 +03001/*-
2 * ============LICENSE_START=======================================================
3 * OSAM
4 * ================================================================================
5 * Copyright (C) 2018 AT&T
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20
21
22
23package org.onap.osam.aai.model;
24
25import com.fasterxml.jackson.annotation.JsonCreator;
26
27import java.util.Map;
28import java.util.Optional;
29import java.util.function.Function;
30import java.util.stream.Collectors;
31import java.util.stream.Stream;
32
33public enum ResourceType {
34
35 SERVICE_INSTANCE("service-instance", "service-instance-name"),
36 GENERIC_VNF("generic-vnf", "vnf-name"),
37 VF_MODULE("vf-module", "vf-module-name"),
38 VOLUME_GROUP("volume-group", "volume-group-name");
39
40 private static Map<String, ResourceType> AAI_FORMAT_MAP = Stream
41 .of(ResourceType.values())
42 .collect(Collectors.toMap(s -> s.aaiFormat, Function.identity()));
43
44 private final String aaiFormat;
45 private final String nameFilter;
46
47 ResourceType(String formatted, String nameFilter) {
48 this.aaiFormat = formatted;
49 this.nameFilter = nameFilter;
50 }
51
52 public String getAaiFormat() {
53 return aaiFormat;
54 }
55
56 public String getNameFilter() {
57 return nameFilter;
58 }
59
60 @JsonCreator
61 public static ResourceType fromString(String string) {
62 return Optional
63 .ofNullable(AAI_FORMAT_MAP.get(string))
64 .orElseThrow(() -> new IllegalArgumentException(string));
65 }
66}