Initial opendaylight infrastructure commit!!
[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     @Override\r
31     public int hashCode() {\r
32         final int prime = 31;\r
33         int result = 1;\r
34         result = prime * result + (absolute ? 1231 : 1237);\r
35         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
36         return result;\r
37     }\r
38 \r
39     @Override\r
40     public boolean equals(Object obj) {\r
41         if (this == obj) {\r
42             return true;\r
43         }\r
44         if (obj == null) {\r
45             return false;\r
46         }\r
47         if (getClass() != obj.getClass()) {\r
48             return false;\r
49         }\r
50         SchemaPath other = (SchemaPath) obj;\r
51         if (absolute != other.absolute) {\r
52             return false;\r
53         }\r
54         if (path == null) {\r
55             if (other.path != null) {\r
56                 return false;\r
57             }\r
58         } else if (!path.equals(other.path)) {\r
59             return false;\r
60         }\r
61         return true;\r
62     }\r
63 \r
64     @Override\r
65     public String toString() {\r
66         StringBuilder builder = new StringBuilder();\r
67         builder.append("SchemaPath [path=");\r
68         builder.append(path);\r
69         builder.append(", absolute=");\r
70         builder.append(absolute);\r
71         builder.append("]");\r
72         return builder.toString();\r
73     }\r
74 }\r