]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph/src/org/simantics/graph/query/PathRoot.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph / src / org / simantics / graph / query / PathRoot.java
1 package org.simantics.graph.query;\r
2 \r
3 public class PathRoot implements Path {\r
4         public final String name;\r
5 \r
6         public PathRoot(String name) {\r
7                 this.name = name;\r
8         }\r
9         \r
10         @Override\r
11         public int hashCode() {\r
12                 final int prime = 31;\r
13                 int result = 1;\r
14                 result = prime * result + ((name == null) ? 0 : name.hashCode());\r
15                 return result;\r
16         }\r
17 \r
18 \r
19         @Override\r
20         public boolean equals(Object obj) {\r
21                 if (this == obj)\r
22                         return true;\r
23                 if (obj == null)\r
24                         return false;\r
25                 if (getClass() != obj.getClass())\r
26                         return false;\r
27                 PathRoot other = (PathRoot) obj;\r
28                 if (name == null) {\r
29                         if (other.name != null)\r
30                                 return false;\r
31                 } else if (!name.equals(other.name))\r
32                         return false;\r
33                 return true;\r
34         }\r
35 \r
36         @Override\r
37         public String toString() {\r
38                 if(name.isEmpty())\r
39                         return "http:/";\r
40                 else\r
41                         return name;\r
42         }\r
43         \r
44         @Override\r
45         public void toString(StringBuilder b) {\r
46                 if(name.isEmpty())\r
47                         b.append("http:/");\r
48                 else\r
49                         b.append(name);\r
50         }\r
51         \r
52         @Override\r
53         public Path child(String childName) {\r
54                 return new PathChild(childName, this);\r
55         }       \r
56 }\r