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