2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
10 import java.util.Collection;
12 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
16 import org.opendaylight.yangtools.yang.data.spi.node.AbstractNormalizedNode;
18 public abstract class AbstractImmutableDataContainerNode<K extends PathArgument, N extends DataContainerNode>
19 extends AbstractNormalizedNode<K, N> implements DataContainerNode {
20 private final Map<PathArgument, Object> children;
22 protected AbstractImmutableDataContainerNode(final Map<PathArgument, Object> children, final K nodeIdentifier) {
23 super(nodeIdentifier);
24 this.children = ImmutableOffsetMap.unorderedCopyOf(children);
28 public final DataContainerChild childByArg(final PathArgument child) {
29 return LazyLeafOperations.getChild(children, child);
33 public final Collection<DataContainerChild> body() {
34 return new LazyValues(children);
38 public final int size() {
39 return children.size();
43 * DO NOT USE THIS METHOD.
46 * This is an implementation-internal API and no outside users should use it. If you do, you are asking for trouble,
47 * as the returned object is not guaranteed to conform to java.util.Map interface, nor is its contents well-defined.
49 * @return An unmodifiable view if this node's children.
51 public final Map<PathArgument, Object> getChildren() {
56 protected int valueHashCode() {
57 return children.hashCode();
61 protected boolean valueEquals(final N other) {
62 if (other instanceof AbstractImmutableDataContainerNode<?, ?> immutableContainer) {
63 return children.equals(immutableContainer.children);
65 if (size() != other.size()) {
68 for (var child : body()) {
69 if (!child.equals(other.childByArg(child.getIdentifier()))) {