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.model.ri.stmt.impl.eff;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import java.util.Optional;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
22 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultWithDataTree;
24 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.AugmentationTargetMixin;
25 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DataSchemaNodeMixin;
26 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.MandatoryMixin;
28 public abstract class AbstractChoiceEffectiveStatement extends DefaultWithDataTree<QName, ChoiceStatement>
29 implements ChoiceEffectiveStatement, ChoiceSchemaNode, DataSchemaNodeMixin<ChoiceStatement>,
30 AugmentationTargetMixin<QName, ChoiceStatement>, MandatoryMixin<QName, ChoiceStatement> {
31 private final int flags;
33 AbstractChoiceEffectiveStatement(final ChoiceStatement declared,
34 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags) {
35 super(declared, substatements);
39 AbstractChoiceEffectiveStatement(final AbstractChoiceEffectiveStatement original, final int flags) {
45 public final int flags() {
50 public final Optional<? extends CaseSchemaNode> findCase(final QName qname) {
51 final SchemaTreeEffectiveStatement<?> child = schemaTreeNamespace().get(requireNonNull(qname));
52 return child instanceof CaseSchemaNode ? Optional.of((CaseSchemaNode) child) : Optional.empty();
56 public final Collection<? extends @NonNull CaseSchemaNode> getCases() {
57 return filterEffectiveStatements(CaseSchemaNode.class);
61 public final ChoiceEffectiveStatement asEffectiveStatement() {