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.ChoiceCaseNode;
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.CaseStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 public final class CaseEffectiveStatementImpl extends AbstractEffectiveSimpleDataNodeContainer<CaseStatement> implements
20 ChoiceCaseNode, DerivableSchemaNode {
22 private final ChoiceCaseNode original;
23 private final boolean configuration;
25 public CaseEffectiveStatementImpl(
26 final StmtContext<QName, CaseStatement, EffectiveStatement<QName, CaseStatement>> ctx) {
28 this.original = (ChoiceCaseNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
30 if (ctx.isConfiguration()) {
31 configuration = ctx.allSubstatementsStream().anyMatch(StmtContext::isConfiguration);
33 configuration = false;
38 public Optional<ChoiceCaseNode> getOriginal() {
39 return Optional.ofNullable(original);
43 public boolean isConfiguration() {
48 public int hashCode() {
51 result = prime * result + Objects.hashCode(getQName());
52 result = prime * result + Objects.hashCode(getPath());
57 public boolean equals(final Object obj) {
64 if (getClass() != obj.getClass()) {
67 CaseEffectiveStatementImpl other = (CaseEffectiveStatementImpl) obj;
68 return Objects.equals(getQName(), other.getQName()) && Objects.equals(getPath(), other.getPath());
72 public String toString() {
73 return CaseEffectiveStatementImpl.class.getSimpleName() + "["
74 + "qname=" + getQName()