2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.sdc.toscaparser.api.parameters;
23 import org.onap.sdc.toscaparser.api.Property;
24 import org.onap.sdc.toscaparser.api.elements.enums.ToscaElementNames;
26 import java.util.ArrayList;
28 import java.util.Optional;
29 import java.util.stream.Collectors;
31 public class Annotation {
33 private static final String HEAT = "HEAT";
36 private ArrayList<Property> properties;
42 @SuppressWarnings("unchecked")
43 public Annotation(Map.Entry<String, Object> annotationEntry) {
44 if (annotationEntry != null) {
45 name = annotationEntry.getKey();
46 Map<String, Object> annValue = (Map<String, Object>) annotationEntry.getValue();
47 type = (String) annValue.get(ToscaElementNames.TYPE.getName());
48 properties = fetchProperties((Map<String, Object>) annValue.get(ToscaElementNames.PROPERTIES.getName()));
52 public String getName() {
56 public void setName(String name) {
60 public String getType() {
64 public void setType(String type) {
68 public ArrayList<Property> getProperties() {
72 public void setProperties(ArrayList<Property> properties) {
73 this.properties = properties;
76 private ArrayList<Property> fetchProperties(Map<String, Object> properties) {
77 if (properties != null) {
78 return (ArrayList<Property>) properties.entrySet().stream()
80 .collect(Collectors.toList());
85 public boolean isHeatSourceType() {
86 if (properties == null) {
89 Optional<Property> sourceType = properties.stream()
90 .filter(p -> p.getName().equals(ToscaElementNames.SOURCE_TYPE.getName()))
92 if (!sourceType.isPresent()) {
95 return sourceType.get().getValue() != null && ((String) sourceType.get().getValue()).equals(HEAT);