Merge "Fix for messags at the boot up time This commit proposes following two sets...
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / RevisionAwareXPathImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.yang.model.util;
9
10 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
11
12 /**
13  * The <code>default</code> implementation of Instance Rewision Aware XPath interface.
14  * 
15  * @see RevisionAwareXPath
16  */
17 public class RevisionAwareXPathImpl implements RevisionAwareXPath {
18
19     private final String xpath;
20     private final boolean absolute;
21
22     public RevisionAwareXPathImpl(String xpath, boolean absolute) {
23         this.xpath = xpath;
24         this.absolute = absolute;
25     }
26
27     @Override
28     public boolean isAbsolute() {
29         return absolute;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = 1;
36         result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
37         result = prime * result + (absolute ? 1231 : 1237);
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (this == obj) {
44             return true;
45         }
46         if (obj == null) {
47             return false;
48         }
49         if (getClass() != obj.getClass()) {
50             return false;
51         }
52         RevisionAwareXPathImpl other = (RevisionAwareXPathImpl) obj;
53         if (xpath == null) {
54             if (other.xpath != null) {
55                 return false;
56             }
57         } else if (!xpath.equals(other.xpath)) {
58             return false;
59         }
60         if (absolute != other.absolute) {
61             return false;
62         }
63         return false;
64     }
65     
66     @Override
67     public String toString() {
68         return xpath;
69     }
70 }