* Interface describing YANG 'leaf-list' statement.
*/
public interface LeafListSchemaNode extends TypedDataSchemaNode, MustConstraintAware, ElementCountConstraintAware,
- EffectiveStatementEquivalent<LeafListEffectiveStatement> {
- /**
- * YANG 'ordered-by' statement. It defines whether the order of entries
- * within this leaf-list are determined by the user or the system. If not
- * present, default is false.
- *
- * @return true if ordered-by argument is "user", false otherwise
- */
- boolean isUserOrdered();
+ UserOrderedAware<LeafListEffectiveStatement> {
/**
* Return the default value of this leaf-list, as per the rules outlined in
*/
public interface ListSchemaNode extends DataNodeContainer, AugmentationTarget, DataSchemaNode, ActionNodeContainer,
NotificationNodeContainer, ElementCountConstraintAware, MustConstraintAware,
- EffectiveStatementEquivalent<ListEffectiveStatement> {
+ UserOrderedAware<ListEffectiveStatement> {
/**
* Returns the list of leaf identifiers.
*
*/
@NonNull List<@NonNull QName> getKeyDefinition();
- /**
- * YANG 'ordered-by' statement. It defines whether the order of entries within a list are determined by the user
- * or the system. If not present, default is false.
- *
- * @return true if ordered-by argument is "user", false otherwise
- */
- boolean isUserOrdered();
-
/**
* Returns unique constraints.
*
--- /dev/null
+/*
+ * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.Ordering;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByAwareEffectiveStatement;
+
+/**
+ * Common interface for {@link DataSchemaNode}s which can have an {@code ordered-by} substatement.
+ *
+ * @param <E> Effective representation of the underlying YANG statement
+ */
+@Beta
+public interface UserOrderedAware<E extends OrderedByAwareEffectiveStatement<?, ?>>
+ extends EffectiveStatementEquivalent<E> {
+ /**
+ * YANG {@code ordered-by} statement. It defines whether the order of entries within this node are determined by the
+ * user or the system. If not present, default is false.
+ *
+ * @return true if ordered-by argument is {@code user}, false otherwise
+ */
+ default boolean isUserOrdered() {
+ return asEffectiveStatement().ordering() == Ordering.USER;
+ }
+}
package org.opendaylight.yangtools.yang.model.api.stmt;
import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+/**
+ * {@link EffectiveStatement} representation of a {@code leaf-list} statement as defined by
+ * <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-7.7">RFC7950</a>.
+ */
@Beta
-public interface LeafListEffectiveStatement extends DataTreeEffectiveStatement<LeafListStatement> {
+public interface LeafListEffectiveStatement extends DataTreeEffectiveStatement<LeafListStatement>,
+ OrderedByAwareEffectiveStatement<QName, LeafListStatement> {
@Override
default StatementDefinition statementDefinition() {
return YangStmtMapping.LEAF_LIST;
import com.google.common.annotations.Beta;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+/**
+ * {@link EffectiveStatement} representation of a {@code list} statement as defined by
+ * <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-7.8">RFC7950</a>.
+ */
@Beta
public interface ListEffectiveStatement extends DataTreeEffectiveStatement<ListStatement>,
- DataTreeAwareEffectiveStatement<QName, ListStatement> {
+ DataTreeAwareEffectiveStatement<QName, ListStatement>, OrderedByAwareEffectiveStatement<QName, ListStatement> {
@Override
default StatementDefinition statementDefinition() {
return YangStmtMapping.LIST;
--- /dev/null
+/*
+ * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api.stmt;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Empty;
+import org.opendaylight.yangtools.yang.common.Ordering;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+
+/**
+ * An {@link EffectiveStatement} which can contain an {@link OrderedByEffectiveStatement}, controlling ordering of
+ * data elements. Absence of an {@code ordered-by} statement implies {@link Ordering#SYSTEM}. YANG statements using
+ * this interface are {@link LeafListEffectiveStatement} and {@link ListEffectiveStatement}.
+ *
+ * @param <A> Argument type ({@link Empty} if statement does not have argument.)
+ * @param <D> Class representing declared version of this statement.
+ */
+@Beta
+public interface OrderedByAwareEffectiveStatement<A, D extends DeclaredStatement<A>> extends EffectiveStatement<A, D> {
+ /**
+ * Return the effective {@link Ordering} of this statement.
+ *
+ * @return Effective ordering
+ */
+ default @NonNull Ordering ordering() {
+ return findFirstEffectiveSubstatementArgument(OrderedByEffectiveStatement.class).orElse(Ordering.SYSTEM);
+ }
+}
import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DataSchemaNodeMixin;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.MustConstraintMixin;
-import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.UserOrderedMixin;
+import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.UserOrderedAwareMixin;
abstract class AbstractLeafListEffectiveStatement
extends AbstractDeclaredEffectiveStatement.Default<QName, LeafListStatement>
- implements LeafListEffectiveStatement, LeafListSchemaNode, UserOrderedMixin<QName, LeafListStatement>,
+ implements LeafListEffectiveStatement, LeafListSchemaNode,
+ UserOrderedAwareMixin<QName, LeafListStatement, LeafListEffectiveStatement>,
DataSchemaNodeMixin<LeafListStatement>, MustConstraintMixin<QName, LeafListStatement> {
private static final VarHandle TYPE;
return flags;
}
- @Override
- public final boolean isUserOrdered() {
- return userOrdered();
- }
-
@Override
public final LeafListEffectiveStatement asEffectiveStatement() {
return this;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DataSchemaNodeMixin;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.MustConstraintMixin;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.NotificationNodeContainerMixin;
-import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.UserOrderedMixin;
+import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.UserOrderedAwareMixin;
import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.WhenConditionMixin;
abstract class AbstractListEffectiveStatement
implements ListEffectiveStatement, ListSchemaNode,
ActionNodeContainerCompat<QName, ListStatement, ListEffectiveStatement>,
NotificationNodeContainerCompat<QName, ListStatement, ListEffectiveStatement>,
- DataSchemaNodeMixin<ListStatement>, UserOrderedMixin<QName, ListStatement>,
+ DataSchemaNodeMixin<ListStatement>, UserOrderedAwareMixin<QName, ListStatement, ListEffectiveStatement>,
DataNodeContainerMixin<QName, ListStatement>, WhenConditionMixin<QName, ListStatement>,
AugmentationTargetMixin<QName, ListStatement>, NotificationNodeContainerMixin<QName, ListStatement>,
ActionNodeContainerMixin<QName, ListStatement>, MustConstraintMixin<QName, ListStatement> {
return flags;
}
- @Override
- public final boolean isUserOrdered() {
- return userOrdered();
- }
-
@Override
public final List<QName> getKeyDefinition() {
return unmaskList(keyDefinition, QName.class);
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UserOrderedAware;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.model.api.WhenConditionAware;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.InputEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByAwareEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OutputEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
*
* @param <A> Argument type ({@link Empty} if statement does not have argument.)
* @param <D> Class representing declared version of this statement.
+ * @param <E> Class representing effective version of this statement.
*/
- public interface UserOrderedMixin<A, D extends DeclaredStatement<A>> extends EffectiveStatementWithFlags<A, D> {
- default boolean userOrdered() {
+ // FIXME: 9.0.0: remove this mixin once we have a properly-cached DataTree and JSON/XML codec tree and the speed
+ // of isUserOrdered() is not really critical.
+ public interface UserOrderedAwareMixin<A, D extends DeclaredStatement<A>,
+ E extends OrderedByAwareEffectiveStatement<A, D>>
+ extends EffectiveStatementWithFlags<A, D>, UserOrderedAware<E> {
+ @Override
+ default boolean isUserOrdered() {
return (flags() & FlagsBuilder.USER_ORDERED) != 0;
}
}