Move NormalizedMetadataWriter to yang-data-api
[yangtools.git] / data / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / OrderedNodeContainer.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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 org.eclipse.jdt.annotation.NonNull;
11
12 /**
13  * A {@link NormalizedNodeContainer} which preserves user supplied ordering and allows addressing of child elements by
14  * position. All implementations of this interface must also implement {@link OrderingAware.User}. This interface should
15  * not be implemented directly, but rather implementing one of it's subclasses
16  * <ul>
17  *   <li>{@link UnkeyedListNode}</li>
18  *   <li>{@link UserLeafSetNode}</li>
19  *   <li>{@link UserMapNode}</li>
20  * </ul>
21  *
22  * @param <V> child type
23  */
24 // FIXME: 9.0.0: we really want to do a List<@NonNull V> body(), but need to reconcile that with key-based lookup in
25 //               implementations -- and those are using only a Map internally.
26 public sealed interface OrderedNodeContainer<V extends NormalizedNode>
27         extends NormalizedNodeContainer<V>, OrderingAware.User
28         permits UnkeyedListNode, UserLeafSetNode, UserMapNode {
29     /**
30      * Returns child node by position.
31      *
32      * @param position Position of child node
33      * @return Child Node
34      * @throws IndexOutOfBoundsException Out of bound Exception
35      */
36     @NonNull V childAt(int position);
37
38     @Override
39     int hashCode();
40
41     @Override
42     boolean equals(Object obj);
43 }