Bug 3874: Support of yang modeled AnyXML - XML deserialization
[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 org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
16 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18
19 @Beta
20 public final class AnyxmlSchemaLocationEffectiveStatementImpl extends
21         UnknownEffectiveStatementBase<SchemaNodeIdentifier> {
22
23     private final SchemaPath path;
24
25     public AnyxmlSchemaLocationEffectiveStatementImpl(
26             final StmtContext<SchemaNodeIdentifier, UnknownStatement<SchemaNodeIdentifier>, ?> ctx) {
27         super(ctx);
28
29         path = ctx.getParentContext().getSchemaPath().get().createChild(getNodeType());
30     }
31
32     @Override
33     public QName getQName() {
34         return getNodeType();
35     }
36
37     @Override
38     public SchemaPath getPath() {
39         return path;
40     }
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + Objects.hashCode(path);
47         result = prime * result + Objects.hashCode(getNodeType());
48         result = prime * result + Objects.hashCode(getNodeParameter());
49         return result;
50     }
51
52     @Override
53     public boolean equals(final Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         AnyxmlSchemaLocationEffectiveStatementImpl other = (AnyxmlSchemaLocationEffectiveStatementImpl) obj;
64         if (!Objects.equals(path, other.path)) {
65             return false;
66         }
67         if (!Objects.equals(getNodeType(), other.getNodeType())) {
68             return false;
69         }
70         if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
71             return false;
72         }
73         return true;
74     }
75 }