6d70d6468a3f14019a5f6af282b318bfa32f80d2
[utils] / system / general / src / main / java / org / wamblee / system / graph / DefaultNode.java
1 /*
2  * Copyright 2008 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.system.graph;
17
18 /**
19  * Default application-independent node. Specific applications of the graph
20  * might implement the Node interface directly.
21  *
22  * @author Erik Brakkee
23  */
24 public class DefaultNode implements Node {
25     /**
26      * DOCUMENT ME!
27      */
28     private String name;
29
30 /**
31      * Constructs the node. 
32      * @param aName Node name. 
33      */
34     public DefaultNode(String aName) {
35         name = aName;
36     }
37
38     /**
39      * Returns the node name.
40      *
41      * @return DOCUMENT ME!
42      */
43     @Override
44     public String getName() {
45         return name;
46     }
47
48     /**
49      * DOCUMENT ME!
50      *
51      * @param aObj DOCUMENT ME!
52      *
53      * @return DOCUMENT ME!
54      */
55     @Override
56     public boolean equals(Object aObj) {
57         if (!(aObj instanceof Node)) {
58             return false;
59         }
60
61         Node node = (Node) aObj;
62
63         return name.equals(node.getName());
64     }
65
66     /**
67      * DOCUMENT ME!
68      *
69      * @return DOCUMENT ME!
70      */
71     @Override
72     public int hashCode() {
73         return name.hashCode();
74     }
75 }