2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.serviceinstancebeans;
23 import java.lang.reflect.InvocationTargetException;
24 import com.google.common.base.CaseFormat;
27 * Enum for Model Type values returned by API Handler to BPMN
29 public enum ModelType {
30 service("serviceInstance"),
33 volumeGroup("volumeGroup"),
35 configuration("configuration"),
36 connectionPoint("connectionPoint"),
38 networkInstanceGroup("networkInstanceGroup"),
39 instanceGroup("instanceGroup");
43 private ModelType(String name) {
48 public <T> T getId(Object obj) {
49 return this.get(obj, "Id");
52 public <T> T getName(Object obj) {
53 return this.get(obj, "Name");
56 public void setId(Object obj, Object value) {
57 this.set(obj, "Id", value);
60 public void setName(Object obj, Object value) {
61 this.set(obj, "Name", value);
64 protected <T> T get(Object obj, String field) {
68 result = (T) obj.getClass().getMethod(String.format("%s%s%s", "get",
69 CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.name), field)).invoke(obj);
70 } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
71 | NoSuchMethodException | SecurityException e) {
79 protected void set(Object obj, String field, Object value) {
84 String.format("%s%s%s", "set",
85 CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, this.name), field),
88 } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
89 | InvocationTargetException e) {