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 java.util.Optional;
13 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
16 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
18 public abstract class AbstractImmutableDataContainerNode<K extends PathArgument>
19 extends AbstractImmutableNormalizedNode<K, Collection<DataContainerChild<? extends PathArgument, ?>>>
20 implements DataContainerNode<K> {
21 private final Map<PathArgument, Object> children;
23 protected AbstractImmutableDataContainerNode(final Map<PathArgument, Object> children, final K nodeIdentifier) {
24 super(nodeIdentifier);
26 this.children = ImmutableOffsetMap.unorderedCopyOf(children);
30 public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
31 return LazyLeafOperations.findChild(children, child);
35 public final Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
36 return LazyLeafOperations.getValue(children);
40 public final int size() {
41 return children.size();
45 protected int valueHashCode() {
46 return children.hashCode();
50 * DO NOT USE THIS METHOD.
53 * This is an implementation-internal API and no outside users should use it. If you do, you are asking for trouble,
54 * as the returned object is not guaranteed to conform to java.util.Map interface, nor is its contents well-defined.
56 * @return An unmodifiable view if this node's children.
58 public final Map<PathArgument, Object> getChildren() {
63 protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
64 return other instanceof AbstractImmutableDataContainerNode<?> && children.equals(
65 ((AbstractImmutableDataContainerNode<?>) other).children);