2 * Copyright (c) 2020 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.api.schema;
10 import java.util.Collection;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
17 * A {@link NormalizedNodeContainer} which contains directly-addressable children. It
20 * NormalizedNodeContainer does not have a value, but it has a child nodes. Definition of possible and valid child nodes
21 * is introduced in subclasses of this interface.
24 * This interface should not be used directly, but rather use of of derived subclasses such as
25 * {@link DataContainerNode}, {@link MapNode}, {@link LeafSetNode}.
27 * @param <I> Path argument type
28 * @param <K> Child path argument type
29 * @param <V> Child Node type
31 public interface DistinctNodeContainer<I extends PathArgument, K extends PathArgument, V extends NormalizedNode>
32 extends NormalizedNodeContainer<I, V> {
37 * All nodes returned in this iterable, MUST also be accessible via {@link #childByArg(PathArgument)} using their
38 * associated identifier.
40 * @return Iteration of all child nodes
43 Collection<@NonNull V> body();
46 * Returns a child node identified by provided key.
48 * @param key Path argument identifying child node
49 * @return Matching child node, or null if no matching child exists
50 * @throws NullPointerException if {@code key} is null
52 @Nullable V childByArg(K key);
55 * Attempts to find a child node identified by provided key.
57 * @param key Path argument identifying child node
58 * @return Optional with child node if child exists. {@link Optional#empty()} if child does not exist
59 * @throws NullPointerException if {@code key} is null
61 default Optional<V> findChildByArg(final K key) {
62 return Optional.ofNullable(childByArg(key));