Do not pretty-print body class
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / StoreTreeNode.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.yangtools.yang.data.api.schema.tree;
9
10 import static com.google.common.base.Verify.verifyNotNull;
11
12 import com.google.common.base.VerifyException;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
17
18 /**
19  * A tree node which has references to its child leaves. These are typically internal non-data leaves, such as
20  * containers, lists, etc.
21  *
22  * @param <C> Final node type
23  */
24 public interface StoreTreeNode<C extends StoreTreeNode<C>> {
25     /**
26      * Returns a direct child of the node.
27      *
28      * @param arg Identifier of child
29      * @return A node if the child is existing, {@code null} otherwise.
30      * @throws NullPointerException when {@code child} is null
31      */
32     @Nullable C childByArg(PathArgument arg);
33
34     /**
35      * Returns a direct child of the node.
36      *
37      * @param arg Identifier of child
38      * @return A child node
39      * @throws NullPointerException when {@code child} is null
40      * @throws VerifyException if the child does not exist
41      */
42     default @NonNull C getChildByArg(final PathArgument arg) {
43         return verifyNotNull(childByArg(arg), "Child %s does not exist");
44     }
45
46     /**
47      * Returns a direct child of the node.
48      *
49      * @param arg Identifier of child
50      * @return Optional with node if the child exists, {@link Optional#empty()} otherwise.
51      * @throws NullPointerException when {@code child} is null
52      */
53     @NonNull default Optional<C> findChildByArg(final PathArgument arg) {
54         return Optional.ofNullable(childByArg(arg));
55     }
56 }