Encapsulate regexes in a non-capturing group
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / 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.yangtools.yang.model.util;
9
10 import java.util.Objects;
11 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
12
13 /**
14  * The <code>helper</code> implementation of Instance Rewision Aware XPath
15  * interface.
16  *
17  * @see RevisionAwareXPath
18  */
19 public class RevisionAwareXPathImpl implements RevisionAwareXPath {
20
21     private final String xpath;
22     private final boolean absolute;
23
24     public RevisionAwareXPathImpl(final String xpath, final boolean absolute) {
25         this.xpath = xpath;
26         this.absolute = absolute;
27     }
28
29     @Override
30     public boolean isAbsolute() {
31         return absolute;
32     }
33
34     @Override
35     public int hashCode() {
36         final int prime = 31;
37         int result = 1;
38         result = prime * result + Objects.hashCode(xpath);
39         result = prime * result + Boolean.hashCode(absolute);
40         return result;
41     }
42
43     @Override
44     public boolean equals(final Object obj) {
45         if (this == obj) {
46             return true;
47         }
48         if (obj == null) {
49             return false;
50         }
51         if (getClass() != obj.getClass()) {
52             return false;
53         }
54         RevisionAwareXPathImpl other = (RevisionAwareXPathImpl) obj;
55         return absolute == other.absolute && Objects.equals(xpath, other.xpath);
56     }
57
58     @Override
59     public String toString() {
60         return xpath;
61     }
62 }