Minor code refactoring.
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / util / MustDefinitionImpl.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.parser.util;
9
10 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
11 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
12
13 final class MustDefinitionImpl implements MustDefinition {
14     private final String mustStr;
15     private final String description;
16     private final String reference;
17     private final String errorAppTag;
18     private final String errorMessage;
19
20     MustDefinitionImpl(String mustStr, String description, String reference, String errorAppTag, String errorMessage) {
21         this.mustStr = mustStr;
22         this.description = description;
23         this.reference = reference;
24         this.errorAppTag = errorAppTag;
25         this.errorMessage = errorMessage;
26     }
27
28     @Override
29     public String getDescription() {
30         return description;
31     }
32
33     @Override
34     public String getErrorAppTag() {
35         return errorAppTag;
36     }
37
38     @Override
39     public String getErrorMessage() {
40         return errorMessage;
41     }
42
43     @Override
44     public String getReference() {
45         return reference;
46     }
47
48     @Override
49     public RevisionAwareXPath getXpath() {
50         return null;
51     }
52
53     @Override
54     public int hashCode() {
55         final int prime = 31;
56         int result = 1;
57         result = prime * result + ((mustStr == null) ? 0 : mustStr.hashCode());
58         result = prime * result + ((description == null) ? 0 : description.hashCode());
59         result = prime * result + ((reference == null) ? 0 : reference.hashCode());
60         return result;
61     }
62
63     @Override
64     public boolean equals(Object obj) {
65         if (this == obj) {
66             return true;
67         }
68         if (obj == null) {
69             return false;
70         }
71         if (getClass() != obj.getClass()) {
72             return false;
73         }
74         final MustDefinitionImpl other = (MustDefinitionImpl) obj;
75         if (mustStr == null) {
76             if (other.mustStr != null) {
77                 return false;
78             }
79         } else if (!mustStr.equals(other.mustStr)) {
80             return false;
81         }
82         if (description == null) {
83             if (other.description != null) {
84                 return false;
85             }
86         } else if (!description.equals(other.description)) {
87             return false;
88         }
89         if (reference == null) {
90             if (other.reference != null) {
91                 return false;
92             }
93         } else if (!reference.equals(other.reference)) {
94             return false;
95         }
96         return true;
97     }
98
99     @Override
100     public String toString() {
101         return mustStr;
102     }
103
104 }