/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.data.impl.schema.nodes; import com.google.common.base.Optional; import java.util.Collections; import java.util.Map; import org.opendaylight.yangtools.concepts.Immutable; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; public abstract class AbstractImmutableDataContainerNode extends AbstractImmutableNormalizedNode>> implements Immutable, DataContainerNode { protected final Map> children; private final Map> publicChildren; public AbstractImmutableDataContainerNode( final Map> children, final K nodeIdentifier) { super(nodeIdentifier); this.children = children; this.publicChildren = Collections.unmodifiableMap(children); } @Override public final Optional> getChild(final PathArgument child) { return Optional.> fromNullable(children.get(child)); } @Override public final Iterable> getValue() { return publicChildren.values(); } @Override protected int valueHashCode() { return children.hashCode(); } public final Map> getChildren() { return publicChildren; } @Override protected boolean valueEquals(final AbstractImmutableNormalizedNode other) { if (!(other instanceof AbstractImmutableDataContainerNode)) { return false; } return children.equals(((AbstractImmutableDataContainerNode)other).children); } }