594c9d385ba02604226b5822db56aa1b17b30219
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / OrderingAware.java
1 /*
2  * Copyright (c) 2020 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.data.api.schema;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.opendaylight.yangtools.concepts.ItemOrder.Ordered;
13 import org.opendaylight.yangtools.concepts.ItemOrder.Unordered;
14 import org.opendaylight.yangtools.yang.common.Ordering;
15
16 /**
17  * Marker interfaces for {@link NormalizedNodeContainer}s which have distinct ordering requirements.
18  */
19 @Beta
20 @NonNullByDefault
21 public interface OrderingAware {
22     /**
23      * Marker interface for NormalizedNodeContainer implementations which correspond to {@code ordered-by system}. These
24      * follow the {@link Unordered} contract.
25      */
26     interface System extends OrderingAware, Unordered {
27         @Override
28         default Ordering ordering() {
29             return Ordering.SYSTEM;
30         }
31     }
32
33     /**
34      * Marker interface for NormalizedNodeContainer implementations which correspond to {@code ordered-by user}. These
35      * follow the {@link Ordered} contract.
36      */
37     interface User extends OrderingAware, Ordered {
38         @Override
39         default Ordering ordering() {
40             return Ordering.USER;
41         }
42     }
43
44     /**
45      * Ordering items within this object.
46      *
47      * @return This object's item ordering.
48      */
49     Ordering ordering();
50 }