Update model.api.Status design
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / HelperMethods.java
1 /*
2  * Copyright (c) 2018 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.yang.model.api;
9
10 import java.util.Optional;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12
13 /**
14  * Package-internal helper methods for use in interface default methods.
15  *
16  * @author Robert Varga
17  */
18 @NonNullByDefault
19 final class HelperMethods {
20     private HelperMethods() {
21
22     }
23
24     static boolean isDataNode(final Optional<DataSchemaNode> optNode) {
25         return optNode.isPresent() && isDataNode(optNode.get());
26     }
27
28     private static boolean isDataNode(final DataSchemaNode node) {
29         return node instanceof ContainerSchemaNode || node instanceof LeafSchemaNode
30                 || node instanceof LeafListSchemaNode || node instanceof ListSchemaNode
31                 || node instanceof AnydataSchemaNode || node instanceof AnyxmlSchemaNode;
32     }
33 }