2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.tosca.update;
26 import java.util.ArrayList;
28 public class Template {
31 * name parameter is used as "key", in the LinkedHashMap of Templates.
34 private ArrayList<String> fields;
36 public Template(String name) {
38 this.fields = new ArrayList<String>();
41 public Template(String name, ArrayList<String> fields) {
46 public String getName() {
50 public void setName(String name) {
54 public ArrayList<String> getFields() {
58 public void setFields(ArrayList<String> fields) {
62 public boolean hasFields(String name) {
63 return fields.contains(name);
66 public void addField(String field) {
70 public void removeField(String field) {
75 * Compare two templates : size and their contents.
77 * @param template the template
80 public boolean checkFields(Template template) {
82 boolean duplicateFields = false;
83 if (template.getFields().size() == this.getFields().size()) {
84 int countMatchingFields = 0;
85 //loop each component of first
86 for (String templateField : template.getFields()) {
87 //if component.key is present in the second
88 if (this.getFields().contains(templateField)) {
89 countMatchingFields++;
93 if (template.getFields().size() == countMatchingFields) {
94 duplicateFields = true;
97 return duplicateFields;
101 public String toString() {
102 return " fields : " + fields;