6e198bef21b3df7f4b7d2065374484d22149cc33
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-api / src / main / java / org / opendaylight / controller / yang / model / api / SchemaPath.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.yang.model.api;\r
9 \r
10 import java.util.ArrayList;\r
11 import java.util.Collections;\r
12 import java.util.List;\r
13 \r
14 import org.opendaylight.controller.yang.common.QName;\r
15 \r
16 public class SchemaPath {\r
17 \r
18     final List<QName> path;\r
19     final boolean absolute;\r
20 \r
21     public SchemaPath(final List<QName> path, boolean absolute) {\r
22         this.path = Collections.unmodifiableList(new ArrayList<QName>(path));\r
23         this.absolute = absolute;\r
24     }\r
25 \r
26     public List<QName> getPath() {\r
27         return path;\r
28     }\r
29 \r
30     public boolean isAbsolute() {\r
31         return absolute;\r
32     }\r
33 \r
34     @Override\r
35     public int hashCode() {\r
36         final int prime = 31;\r
37         int result = 1;\r
38         result = prime * result + (absolute ? 1231 : 1237);\r
39         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
40         return result;\r
41     }\r
42 \r
43     @Override\r
44     public boolean equals(Object obj) {\r
45         if (this == obj) {\r
46             return true;\r
47         }\r
48         if (obj == null) {\r
49             return false;\r
50         }\r
51         if (getClass() != obj.getClass()) {\r
52             return false;\r
53         }\r
54         SchemaPath other = (SchemaPath) obj;\r
55         if (absolute != other.absolute) {\r
56             return false;\r
57         }\r
58         if (path == null) {\r
59             if (other.path != null) {\r
60                 return false;\r
61             }\r
62         } else if (!path.equals(other.path)) {\r
63             return false;\r
64         }\r
65         return true;\r
66     }\r
67 \r
68     @Override\r
69     public String toString() {\r
70         StringBuilder builder = new StringBuilder();\r
71         builder.append("SchemaPath [path=");\r
72         builder.append(path);\r
73         builder.append(", absolute=");\r
74         builder.append(absolute);\r
75         builder.append("]");\r
76         return builder.toString();\r
77     }\r
78 }\r