Add support for RFC6536 extensions
[yangtools.git] / yang / rfc6536-model-api / src / main / java / org / opendaylight / yangtools / rfc6536 / model / api / DefaultDenyAllSchemaNode.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies 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.rfc6536.model.api;
9
10 import com.google.common.annotations.Beta;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
14
15 /**
16  * Represents the effect of 'default-deny-all' extension, as defined in
17  * <a href="https://tools.ietf.org/html/rfc6536">RFC6536</a>, being attached to a SchemaNode.
18  */
19 @Beta
20 public interface DefaultDenyAllSchemaNode extends UnknownSchemaNode {
21     /**
22      * Attempt to find a {@link DefaultDenyAllSchemaNode} in a parent {@link DataSchemaNode}.
23      *
24      * @param parent Parent to search
25      * @return {@link DefaultDenyAllSchemaNode} child, if present.
26      */
27     static Optional<DefaultDenyAllSchemaNode> findIn(final DataSchemaNode parent) {
28         return parent.getUnknownSchemaNodes().stream().filter(DefaultDenyAllSchemaNode.class::isInstance).findAny()
29                 .map(DefaultDenyAllSchemaNode.class::cast);
30     }
31 }