414b7137c7c9a125c952ede12d0d985b02100760
[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 interface NormalizedNodeContainer<V extends NormalizedNode> extends NormalizedNode, OrderingAware {
21     /**
22      * {@inheritDoc}
23      *
24      * <p>
25      * Returns iteration of all child nodes. Order of returned child nodes may be defined by subinterfaces.
26      */
27     @Override
28     Collection<@NonNull V> body();
29
30     /**
31      * Return the logical size of this container body. The default implementation defers to {@code body().size()}.
32      *
33      * @return Size of this container's body.
34      */
35     default int size() {
36         return body().size();
37     }
38
39     /**
40      * Determine whether this container body is empty. The default implementation defers to {@code body().isEmpty()}.
41      *
42      * @return True if this container has an empty body.
43      */
44     default boolean isEmpty() {
45         return body().isEmpty();
46     }
47 }