Seal NormalizedNodeContainer
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / NormalizedNodeContainer.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;
9
10 import java.util.Collection;
11 import org.eclipse.jdt.annotation.NonNull;
12
13 /**
14  * Node which is not leaf, but has child {@link NormalizedNode}s as its value. It provides iteration over its child
15  * nodes via {@link #body()}. More convenient access to child nodes are provided by {@link DistinctNodeContainer} and
16  * {@link OrderedNodeContainer}.
17  *
18  * @param <V> Child Node type
19  */
20 public sealed interface NormalizedNodeContainer<V extends NormalizedNode> extends NormalizedNode, OrderingAware
21         permits DistinctNodeContainer, OrderedNodeContainer {
22     /**
23      * {@inheritDoc}
24      *
25      * <p>
26      * Returns iteration of all child nodes. Order of returned child nodes may be defined by subinterfaces.
27      */
28     @Override
29     Collection<@NonNull V> body();
30
31     /**
32      * Return the logical size of this container body. The default implementation defers to {@code body().size()}.
33      *
34      * @return Size of this container's body.
35      */
36     default int size() {
37         return body().size();
38     }
39
40     /**
41      * Determine whether this container body is empty. The default implementation defers to {@code body().isEmpty()}.
42      *
43      * @return True if this container has an empty body.
44      */
45     default boolean isEmpty() {
46         return body().isEmpty();
47     }
48 }