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 com.google.common.base.Optional;
11 import java.util.Collection;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.util.ImmutableOffsetMap;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
17 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
19 public abstract class AbstractImmutableDataContainerNode<K extends PathArgument> extends AbstractImmutableNormalizedNode<K, Collection<DataContainerChild<? extends PathArgument, ?>>> implements Immutable, DataContainerNode<K> {
20 private final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children;
22 public AbstractImmutableDataContainerNode(
23 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children, final K nodeIdentifier) {
24 super(nodeIdentifier);
26 this.children = ImmutableOffsetMap.copyOf(children);
30 public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
31 return Optional.<DataContainerChild<? extends PathArgument, ?>> fromNullable(children.get(child));
35 public final Collection<DataContainerChild<? extends PathArgument, ?>> getValue() {
36 return children.values();
40 protected int valueHashCode() {
41 return children.hashCode();
45 * DO NOT USE THIS METHOD.
47 * This is an implementation-internal API and no outside users should use it. If you do,
48 * you are asking for trouble, as the returned object is not guaranteed to conform to
49 * java.util.Map interface.
51 * @return An unmodifiable view if this node's children.
53 public final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> getChildren() {
58 protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
59 if (!(other instanceof AbstractImmutableDataContainerNode<?>)) {
63 return children.equals(((AbstractImmutableDataContainerNode<?>)other).children);