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;
12 import org.opendaylight.yangtools.concepts.Immutable;
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> extends AbstractImmutableNormalizedNode<K, Iterable<DataContainerChild<? extends PathArgument, ?>>> implements Immutable, DataContainerNode<K> {
18 private final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children;
20 public AbstractImmutableDataContainerNode(
21 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children, final K nodeIdentifier) {
22 super(nodeIdentifier);
24 this.children = UnmodifiableChildrenMap.create(children);
28 public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
29 return Optional.<DataContainerChild<? extends PathArgument, ?>> fromNullable(children.get(child));
33 public final Iterable<DataContainerChild<? extends PathArgument, ?>> getValue() {
34 return children.values();
38 protected int valueHashCode() {
39 return children.hashCode();
43 * DO NOT USE THIS METHOD.
45 * This is an implementation-internal API and no outside users should use it. If you do,
46 * you are asking for trouble, as the returned object is not guaranteed to conform to
47 * java.util.Map interface.
49 * @return An unmodifiable view if this node's children.
51 public final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> getChildren() {
56 protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
57 if (!(other instanceof AbstractImmutableDataContainerNode<?>)) {
61 return children.equals(((AbstractImmutableDataContainerNode<?>)other).children);