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;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
17 import com.google.common.base.Optional;
18 import com.google.common.collect.Iterables;
20 public abstract class AbstractImmutableDataContainerNode<K extends PathArgument> //
21 extends AbstractImmutableNormalizedNode<K, Iterable<DataContainerChild<? extends PathArgument, ?>>> //
22 implements Immutable, DataContainerNode<K> {
24 protected final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children;
27 public AbstractImmutableDataContainerNode(
28 final Map<PathArgument, DataContainerChild<? extends PathArgument, ?>> children, final K nodeIdentifier) {
29 super(nodeIdentifier, Iterables.unmodifiableIterable(children.values()));
30 this.children = children;
34 public final Optional<DataContainerChild<? extends PathArgument, ?>> getChild(final PathArgument child) {
35 return Optional.<DataContainerChild<? extends PathArgument, ?>> fromNullable(children.get(child));
39 protected int valueHashCode() {
40 return children.hashCode();
44 protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
45 if (!(other instanceof AbstractImmutableDataContainerNode<?>)) {
49 return children.equals(((AbstractImmutableDataContainerNode<?>)other).children);