/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.model.api; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.NoSuchElementException; import java.util.Optional; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.common.QName; /** * Node which can contains other nodes. */ public interface DataNodeContainer { /** * Returns set of all newly defined types within this DataNodeContainer. * * @return typedef statements in lexicographical order */ Collection extends TypeDefinition>> getTypeDefinitions(); /** * Returns set of all child nodes defined within this DataNodeContainer. Although the return type is a collection, * each node is guaranteed to be present at most once. * *
* Note that the nodes returned are NOT {@code data nodes}, but rather {@link DataSchemaNode}s, * hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are present instead of their children. This * is consistent with {@code schema tree}. * * @return child nodes in lexicographical order */ Collection extends DataSchemaNode> getChildNodes(); /** * Returns set of all groupings defined within this DataNodeContainer. * * @return grouping statements in lexicographical order */ Collection extends GroupingDefinition> getGroupings(); /** * Returns the child node corresponding to the specified name. * *
* Note that the nodes searched are NOT {@code data nodes}, but rather {@link DataSchemaNode}s, * hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are returned instead of their matching children. This * is consistent with {@code schema tree}. * * @param name QName of child * @return child node of this DataNodeContainer if child with given name is present, null otherwise * @throws NullPointerException if {@code name} is null */ default @Nullable DataSchemaNode dataChildByName(final QName name) { return findDataChildByName(name).orElse(null); } /** * Returns the child node corresponding to the specified name. * *
* Note that the nodes searched are NOT {@code data nodes}, but rather {@link DataSchemaNode}s, * hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are returned instead of their matching children. This * is consistent with {@code schema tree}. * * @param name QName of child * @return child node of this DataNodeContainer if child with given name is present, null otherwise * @throws NullPointerException if {@code name} is null * @deprecated Use {@link #dataChildByName(QName)} or {@link #findDataChildByName(QName)} instead. This method will * be repurposed to assert existence in the next major release. */ @Deprecated(forRemoval = true) default @Nullable DataSchemaNode getDataChildByName(final QName name) { return dataChildByName(name); } /** * Returns the child node corresponding to the specified name. * *
* Note that the nodes searched are NOT {@code data nodes}, but rather {@link DataSchemaNode}s,
* hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are returned instead of their matching children.
*
* @param name QName of child
* @return child node of this DataNodeContainer if child with given name is present, empty otherwise
* @throws NullPointerException if {@code name} is null
*/
Optional
* Note that the nodes searched are NOT {@code data nodes}, but rather {@link DataSchemaNode}s,
* hence {@link ChoiceSchemaNode} and {@link CaseSchemaNode} are returned instead of their matching children.
*
* @param first QName of first child
* @param others QNames of subsequent children
* @return child node of this DataNodeContainer if child with given name is present, empty otherwise
* @throws NullPointerException if any argument is null
*/
default Optional