Populate data/ hierarchy
[yangtools.git] / model / rfc8528-model-api / src / main / java / org / opendaylight / yangtools / rfc8528 / model / api / MountPointSchemaNode.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech s.r.o. 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.rfc8528.model.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.stream.Stream;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
16
17 /**
18  * Represents the effect of 'mount-point' extension, as defined in
19  * <a href="https://tools.ietf.org/html/rfc8528">RFC8528</a>, being attached to a SchemaNode.
20  */
21 @Beta
22 public interface MountPointSchemaNode extends UnknownSchemaNode {
23     /**
24      * Find all mount points defined in a {@link ContainerSchemaNode}.
25      *
26      * @param schema ContainerSchemaNode to search
27      * @return {@link MountPointSchemaNode}s defined the ContainerSchemaNode.
28      * @throws NullPointerException if context is null
29      */
30     static @NonNull Stream<MountPointSchemaNode> streamAll(final ContainerSchemaNode schema) {
31         return schema.getUnknownSchemaNodes().stream()
32                 .filter(MountPointSchemaNode.class::isInstance)
33                 .map(MountPointSchemaNode.class::cast);
34     }
35
36     /**
37      * Find all mount points defined in a {@link ListSchemaNode}.
38      *
39      * @param schema ListSchemaNode to search
40      * @return {@link MountPointSchemaNode}s defined the ListSchemaNode.
41      * @throws NullPointerException if context is null
42      */
43     static @NonNull Stream<MountPointSchemaNode> streamAll(final ListSchemaNode schema) {
44         return schema.getUnknownSchemaNodes().stream()
45                 .filter(MountPointSchemaNode.class::isInstance)
46                 .map(MountPointSchemaNode.class::cast);
47     }
48
49     @Override
50     MountPointEffectiveStatement asEffectiveStatement();
51 }