2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.data.util;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableSet;
14 import java.util.Collection;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.model.api.UsesNode;
24 * Utility DataNodeContainer containing only the specified node.
27 public final class SingleChildDataNodeContainer implements DataNodeContainer {
28 private final DataSchemaNode child;
30 public SingleChildDataNodeContainer(final DataSchemaNode child) {
31 this.child = requireNonNull(child);
35 public DataSchemaNode dataChildByName(final QName name) {
36 return child.getQName().equals(name) ? child : null;
40 public Collection<DataSchemaNode> getChildNodes() {
41 return ImmutableSet.of(child);
45 public Set<TypeDefinition<?>> getTypeDefinitions() {
46 return ImmutableSet.of();
50 public Set<GroupingDefinition> getGroupings() {
51 return ImmutableSet.of();
55 public Set<UsesNode> getUses() {
56 return ImmutableSet.of();