Merge "AAI-1523 Tweak onap-java-formatter.xml"
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / genxsd / DeleteFootnoteSet.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 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
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 package org.onap.aai.util.genxsd;
21
22 import java.util.Set;
23 import java.util.TreeSet;
24
25 public class DeleteFootnoteSet {
26         protected Set<String> footnotes = new TreeSet<>();
27         protected String targetNode = "<NodeType>";
28         public DeleteFootnoteSet(String targetNode) {
29                 super();
30                 this.targetNode = targetNode == null ? "" : targetNode;
31         }
32
33         public void add(String s ) {
34                 String fullnote=null;
35                 if("(1)".equals(s)) {
36                         fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this FROM node is DELETED also";
37                 } else if("(2)".equals(s)) {
38                         fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this TO node is DELETED also";
39                 } else if("(3)".equals(s)) {
40                         fullnote = s+" IF this FROM node is deleted, this "+targetNode.toUpperCase()+" is DELETED also";
41                 } else if("(4)".equals(s)) {
42                         fullnote = s+" IF this TO node is deleted, this "+targetNode.toUpperCase()+" is DELETED also";
43                 } else if(s.contains(targetNode.toUpperCase())) {
44                         fullnote = s;
45                 } else {
46                         return;
47                 }
48                 footnotes.add(fullnote);
49         }
50
51         public String toString() {
52                 StringBuilder sb = new StringBuilder();
53                 if(footnotes.size() > 0) sb.append("\n      -");
54                 sb.append(String.join("\n      -", footnotes)+"\n");
55                 return sb.toString();
56         }
57 }