8f2809e19c45913f483f3410a36d8e72ae0cf771
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / rt / AbstractChoiceRuntimeType.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.mdsal.binding.generator.impl.rt;
9
10 import com.google.common.collect.Collections2;
11 import java.util.Collection;
12 import java.util.List;
13 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
14 import org.opendaylight.mdsal.binding.model.api.JavaTypeName;
15 import org.opendaylight.mdsal.binding.runtime.api.AugmentRuntimeType;
16 import org.opendaylight.mdsal.binding.runtime.api.CaseRuntimeType;
17 import org.opendaylight.mdsal.binding.runtime.api.ChoiceRuntimeType;
18 import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceEffectiveStatement;
20
21 abstract class AbstractChoiceRuntimeType extends AbstractCompositeRuntimeType<ChoiceEffectiveStatement>
22         implements ChoiceRuntimeType {
23     AbstractChoiceRuntimeType(final GeneratedType bindingType, final ChoiceEffectiveStatement statement,
24             final List<RuntimeType> children, final List<AugmentRuntimeType> augments) {
25         super(bindingType, statement, children, augments);
26     }
27
28     @Override
29     public final Collection<CaseRuntimeType> validCaseChildren() {
30         return (Collection) Collections2.filter(schemaTreeChildren(), CaseRuntimeType.class::isInstance);
31     }
32
33     @Override
34     public final CaseRuntimeType bindingCaseChild(final JavaTypeName typeName) {
35         final var child = bindingChild(typeName);
36         return child instanceof CaseRuntimeType ? (CaseRuntimeType) child : null;
37     }
38 }