Changed to unmaintained
[appc.git] / appc-dg / appc-dg-shared / appc-dg-dependency-model / src / main / java / org / onap / appc / dg / objects / Node.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.dg.objects;
25
26 import java.util.LinkedList;
27 import java.util.List;
28
29
30 public class Node<T> {
31     T child;
32     List<T> parents;
33
34     @Override
35     public int hashCode(){
36         return child.hashCode();
37     }
38
39     @Override
40     public boolean equals(Object object){
41         if(object == null){
42             return false;
43         }
44         if(!(object instanceof Node)){
45             return false;
46         }
47         Node node = (Node)object;
48         return this.child.equals(node.getChild());
49     }
50
51     public Node(T child){
52         this.child = child;
53         this.parents = new LinkedList<>();
54     }
55
56     public T getChild() {
57         return child;
58     }
59
60     public List<T> getParents() {
61         return parents;
62     }
63
64     public void addParent(T parent){
65         this.parents.add(parent);
66     }
67
68     @Override
69     public String toString() {
70         StringBuilder stringBuilder = new StringBuilder("Node : child = " + child + " , parents = ");
71         for(T parent:parents){
72             stringBuilder.append(parent).append(",");
73         }
74         return stringBuilder.toString();
75     }
76 }