Add instructions to invoke the linter and code formatter plugins to the README and...
[aai/schema-service.git] / aai-schema-gen / src / main / java / org / onap / aai / schemagen / 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
21 package org.onap.aai.schemagen.genxsd;
22
23 import java.util.Set;
24 import java.util.TreeSet;
25
26 public class DeleteFootnoteSet {
27     protected Set<String> footnotes = new TreeSet<>();
28     protected String targetNode = "<NodeType>";
29
30     public DeleteFootnoteSet(String targetNode) {
31         super();
32         this.targetNode = targetNode == null ? "" : targetNode;
33     }
34
35     public void add(String s) {
36         String fullnote = null;
37         if ("(1)".equals(s)) {
38             fullnote = s + " IF this " + targetNode.toUpperCase()
39                 + " node is deleted, this FROM node is DELETED also";
40         } else if ("(2)".equals(s)) {
41             fullnote = s + " IF this " + targetNode.toUpperCase()
42                 + " node is deleted, this TO node is DELETED also";
43         } else if ("(3)".equals(s)) {
44             fullnote = s + " IF this FROM node is deleted, this " + targetNode.toUpperCase()
45                 + " is DELETED also";
46         } else if ("(4)".equals(s)) {
47             fullnote = s + " IF this TO node is deleted, this " + targetNode.toUpperCase()
48                 + " is DELETED also";
49         } else if (s.contains(targetNode.toUpperCase())) {
50             fullnote = s;
51         } else {
52             return;
53         }
54         footnotes.add(fullnote);
55     }
56
57     public String toString() {
58         StringBuilder sb = new StringBuilder();
59         if (footnotes.size() > 0)
60             sb.append("\n      -");
61         sb.append(String.join("\n      -", footnotes) + "\n");
62         return sb.toString();
63     }
64 }