2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.api;
10 import java.util.ArrayList;
11 import java.util.Collections;
12 import java.util.List;
14 import org.opendaylight.yangtools.yang.common.QName;
18 * Represents unique path to the every node inside the module.
21 public class SchemaPath {
22 private final int hashBooleanTrue = 1231;
23 private final int hashBooleanFalse = 1237;
26 * List of QName instances which represents complete path to the node.
28 private final List<QName> path;
31 * Boolean value which represents type of schema path (relative or
34 private final boolean absolute;
37 * Constructs new instance of this class with the concrete path.
40 * list of QName instances which specifies exact path to the
43 * boolean value which specifies if the path is absolute or
46 public SchemaPath(final List<QName> path, boolean absolute) {
47 this.path = Collections.unmodifiableList(new ArrayList<QName>(path));
48 this.absolute = absolute;
52 * Returns the complete path to schema node.
54 * @return list of <code>QName</code> instances which represents complete
57 public List<QName> getPath() {
62 * Describes whether schema path is|isn't absolute.
64 * @return boolean value which is <code>true</code> if schema path is
67 public boolean isAbsolute() {
72 public int hashCode() {
75 result = prime * result + (absolute ? hashBooleanTrue : hashBooleanFalse);
76 result = prime * result + ((path == null) ? 0 : path.hashCode());
81 public boolean equals(Object obj) {
88 if (getClass() != obj.getClass()) {
91 SchemaPath other = (SchemaPath) obj;
92 if (absolute != other.absolute) {
96 if (other.path != null) {
99 } else if (!path.equals(other.path)) {
106 public String toString() {
107 StringBuilder builder = new StringBuilder();
108 builder.append("SchemaPath [path=");
109 builder.append(path);
110 builder.append(", absolute=");
111 builder.append(absolute);
113 return builder.toString();