Bump Xtend to 2.35.0
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / stmt / OrderedByAwareEffectiveStatement.java
1 /*
2  * Copyright (c) 2022 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.yang.model.api.stmt;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.yang.common.Empty;
12 import org.opendaylight.yangtools.yang.common.Ordering;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15
16 /**
17  * An {@link EffectiveStatement} which can contain an {@link OrderedByEffectiveStatement}, controlling ordering of
18  * data elements. Absence of an {@code ordered-by} statement implies {@link Ordering#SYSTEM}. YANG statements using
19  * this interface are {@link LeafListEffectiveStatement} and {@link ListEffectiveStatement}.
20  *
21  * @param <A> Argument type ({@link Empty} if statement does not have argument.)
22  * @param <D> Class representing declared version of this statement.
23  */
24 public interface OrderedByAwareEffectiveStatement<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
25     /**
26      * Return the effective {@link Ordering} of this statement.
27      *
28      * @return Effective ordering
29      */
30     default @NonNull Ordering ordering() {
31         return findFirstEffectiveSubstatementArgument(OrderedByEffectiveStatement.class).orElse(Ordering.SYSTEM);
32     }
33 }