2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 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.tosca.parser.elements;
23 import org.onap.sdc.tosca.parser.api.IEntityDetails;
24 import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
25 import org.onap.sdc.toscaparser.api.CapabilityAssignment;
26 import org.onap.sdc.toscaparser.api.EntityTemplate;
27 import org.onap.sdc.toscaparser.api.Property;
28 import org.onap.sdc.toscaparser.api.RequirementAssignment;
30 import java.util.Collections;
31 import java.util.List;
33 import java.util.stream.Collectors;
35 public abstract class EntityDetails implements IEntityDetails {
37 private final EntityTemplate entityTemplate;
38 private final IEntityDetails parentNodeTemplate;
40 EntityDetails(EntityTemplate entityTemplate) {
41 this.entityTemplate = entityTemplate;
42 this.parentNodeTemplate = EntityDetailsFactory.createEntityDetails(EntityTemplateType.NODE_TEMPLATE, entityTemplate.getParentNodeTemplate());
46 public String getName() {
47 return entityTemplate.getName();
50 EntityTemplate getEntityTemplate() {
51 return entityTemplate;
55 public Map<String, Property> getProperties() {
56 return entityTemplate.getProperties();
60 public List<IEntityDetails> getMemberNodes() {
61 return Collections.emptyList();
65 public IEntityDetails getParent() {
66 return parentNodeTemplate;
70 public List<RequirementAssignment> getRequirements() {
71 return entityTemplate.getRequirements()
76 public List<CapabilityAssignment> getCapabilities() {
77 return entityTemplate.getCapabilities()
82 public List<String> getTargets() {
83 return Collections.emptyList();
87 public List<IEntityDetails> getTargetEntities() {
88 return Collections.emptyList();
92 public String getPath() {
93 StringBuilder pathBld = new StringBuilder("");
94 EntityTemplate currentEntityParent = entityTemplate.getParentNodeTemplate();
96 while (currentEntityParent != null) {
97 if (pathBld.length() != 0) {
98 pathBld.insert(0,"#");
100 pathBld.insert(0, currentEntityParent.getName());
101 currentEntityParent = currentEntityParent.getParentNodeTemplate();
103 return pathBld.toString();
107 public String getToscaType() {
108 return entityTemplate.getType();
112 public List<String> getMembers() { return Collections.emptyList(); }