Merge "Introduced skeletons of Contributor and User guide."
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / StatementIdentifier.java
1 /*
2  * Copyright (c) 2015 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.parser.stmt.reactor;
9
10 import com.google.common.base.Objects;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
13 import javax.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.common.QName;
15
16 class StatementIdentifier {
17
18     private final @Nonnull QName name;
19     private final @Nullable String argument;
20
21     StatementIdentifier(QName name, String argument) {
22         this.name = Preconditions.checkNotNull(name);
23         this.argument = argument;
24     }
25
26     QName getName() {
27         return name;
28     }
29
30     String getArgument() {
31         return argument;
32     }
33
34     @Override
35     public int hashCode() {
36         final int prime = 31;
37         int result = 1;
38         result = prime * result +  name.hashCode();
39         result = prime * result + ((argument == null) ? 0 : argument.hashCode());
40         return result;
41     }
42
43     @Override
44     public boolean equals(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         StatementIdentifier other = (StatementIdentifier) obj;
55         if (!name.equals(other.name)) {
56             return false;
57         }
58         if (!Objects.equal(argument, other.argument)) {
59             return false;
60         }
61         return true;
62     }
63
64     @Override
65     public String toString() {
66         return "StatementIdentifier [name=" + name + ", argument=" + argument + "]";
67     }
68
69
70 }