2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
10 import java.util.Objects;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 public class AnyxmlEffectiveStatementImpl extends AbstractEffectiveDataSchemaNode<AnyxmlStatement>
22 implements AnyxmlEffectiveStatement, AnyXmlSchemaNode, DerivableSchemaNode {
24 private final AnyXmlSchemaNode original;
25 private final boolean mandatory;
27 public AnyxmlEffectiveStatementImpl(
28 final StmtContext<QName, AnyxmlStatement, EffectiveStatement<QName, AnyxmlStatement>> ctx) {
30 this.original = (AnyXmlSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
31 final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
32 mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
36 public boolean isMandatory() {
41 public Optional<AnyXmlSchemaNode> getOriginal() {
42 return Optional.ofNullable(original);
46 public int hashCode() {
49 result = prime * result + Objects.hashCode(getQName());
50 result = prime * result + Objects.hashCode(getPath());
55 public boolean equals(final Object obj) {
62 if (getClass() != obj.getClass()) {
66 AnyxmlEffectiveStatementImpl other = (AnyxmlEffectiveStatementImpl) obj;
67 return Objects.equals(getQName(), other.getQName()) && Objects.equals(getPath(), other.getPath());
71 public String toString() {
72 return AnyxmlEffectiveStatementImpl.class.getSimpleName() + "["
73 + "qname=" + getQName()
74 + ", path=" + getPath()