Propagate @Nonnull and @Nullable annotations
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / AnyxmlSchemaLocationEffectiveStatementImpl.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
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
10
11 import com.google.common.annotations.Beta;
12 import java.util.Objects;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19
20 @Beta
21 public final class AnyxmlSchemaLocationEffectiveStatementImpl extends
22         UnknownEffectiveStatementBase<SchemaNodeIdentifier> {
23
24     private final SchemaPath path;
25
26     public AnyxmlSchemaLocationEffectiveStatementImpl(
27             final StmtContext<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, ?> ctx) {
28         super(ctx);
29
30         path = ctx.getParentContext().getSchemaPath().get().createChild(getNodeType());
31     }
32
33     @Nonnull
34     @Override
35     public QName getQName() {
36         return getNodeType();
37     }
38
39     @Nonnull
40     @Override
41     public SchemaPath getPath() {
42         return path;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = 1;
49         result = prime * result + Objects.hashCode(path);
50         result = prime * result + Objects.hashCode(getNodeType());
51         result = prime * result + Objects.hashCode(getNodeParameter());
52         return result;
53     }
54
55     @Override
56     public boolean equals(final Object obj) {
57         if (this == obj) {
58             return true;
59         }
60         if (obj == null) {
61             return false;
62         }
63         if (getClass() != obj.getClass()) {
64             return false;
65         }
66         AnyxmlSchemaLocationEffectiveStatementImpl other = (AnyxmlSchemaLocationEffectiveStatementImpl) obj;
67         if (!Objects.equals(path, other.path)) {
68             return false;
69         }
70         if (!Objects.equals(getNodeType(), other.getNodeType())) {
71             return false;
72         }
73         if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
74             return false;
75         }
76         return true;
77     }
78 }