Add OrderedByAwareEffectiveStatement
[yangtools.git] / model / yang-model-ri / src / main / java / org / opendaylight / yangtools / yang / model / ri / stmt / impl / eff / RegularChoiceEffectiveStatement.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.yang.model.ri.stmt.impl.eff;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ImmutableList;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
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.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
20
21 public final class RegularChoiceEffectiveStatement extends AbstractChoiceEffectiveStatement {
22     private final CaseSchemaNode defaultCase;
23     private final @NonNull QName argument;
24
25     public RegularChoiceEffectiveStatement(final ChoiceStatement declared,
26             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final QName argument,
27             final int flags, final @Nullable CaseSchemaNode defaultCase) {
28         super(declared, substatements, flags);
29         this.argument = requireNonNull(argument);
30         this.defaultCase = defaultCase;
31     }
32
33     public RegularChoiceEffectiveStatement(final AbstractChoiceEffectiveStatement original, final QName argument,
34             final int flags) {
35         super(original, flags);
36         this.argument = requireNonNull(argument);
37         defaultCase = original.getDefaultCase().orElse(null);
38     }
39
40     @Override
41     public QName argument() {
42         return argument;
43     }
44
45     @Override
46     public Optional<CaseSchemaNode> getDefaultCase() {
47         return Optional.ofNullable(defaultCase);
48     }
49 }