Drop @Beta from mdsal.binding.generator.impl.rt
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / rt / DefaultModuleRuntimeType.java
1 /*
2  * Copyright (c) 2021 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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ImmutableMap;
13 import com.google.common.collect.Maps;
14 import java.util.List;
15 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
16 import org.opendaylight.mdsal.binding.runtime.api.ModuleRuntimeType;
17 import org.opendaylight.mdsal.binding.runtime.api.RuntimeType;
18 import org.opendaylight.mdsal.binding.runtime.api.YangDataRuntimeType;
19 import org.opendaylight.yangtools.yang.common.YangDataName;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
21
22 public final class DefaultModuleRuntimeType extends AbstractCompositeRuntimeType<ModuleEffectiveStatement>
23         implements ModuleRuntimeType {
24     private final ImmutableMap<YangDataName, YangDataRuntimeType> yangDataChildren;
25
26     public DefaultModuleRuntimeType(final GeneratedType bindingType, final ModuleEffectiveStatement statement,
27             final List<RuntimeType> children, final List<YangDataRuntimeType> yangDataChildren) {
28         super(bindingType, statement, children);
29         this.yangDataChildren = Maps.uniqueIndex(yangDataChildren, type -> type.statement().argument());
30     }
31
32     @Override
33     public YangDataRuntimeType yangDataChild(final YangDataName templateName) {
34         return yangDataChildren.get(requireNonNull(templateName));
35     }
36 }