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;
17 public abstract class AbstractImmutableDataContainerNode<K extends PathArgument, N extends DataContainerNode<K>>
18 extends AbstractImmutableNormalizedNode<K, N> implements DataContainerNode<K> {
19 private final Map<PathArgument, Object> children;
21 protected AbstractImmutableDataContainerNode(final Map<PathArgument, Object> children, final K nodeIdentifier) {
22 super(nodeIdentifier);
23 this.children = ImmutableOffsetMap.unorderedCopyOf(children);
27 public final DataContainerChild childByArg(final PathArgument child) {
28 return LazyLeafOperations.getChild(children, child);
32 public final Collection<DataContainerChild> body() {
33 return new LazyValues(children);
37 public final int size() {
38 return children.size();
42 * DO NOT USE THIS METHOD.
45 * This is an implementation-internal API and no outside users should use it. If you do, you are asking for trouble,
46 * as the returned object is not guaranteed to conform to java.util.Map interface, nor is its contents well-defined.
48 * @return An unmodifiable view if this node's children.
50 public final Map<PathArgument, Object> getChildren() {
55 protected int valueHashCode() {
56 return children.hashCode();
60 protected boolean valueEquals(final N other) {
61 return other instanceof AbstractImmutableDataContainerNode<?, ?> && children.equals(
62 ((AbstractImmutableDataContainerNode<?, ?>) other).children);