/* * 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.builder.impl; import java.util.List; import java.util.Map; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode; import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import com.google.common.collect.Maps; abstract class AbstractImmutableDataContainerNodeBuilder> implements DataContainerNodeBuilder { protected Map> value; protected I nodeIdentifier; protected AbstractImmutableDataContainerNodeBuilder() { this.value = Maps.newLinkedHashMap(); } @Override public DataContainerNodeBuilder withValue(List> value) { // TODO Replace or putAll ? for (DataContainerChild dataContainerChild : value) { withChild(dataContainerChild); } return this; } @Override public DataContainerNodeBuilder withChild(DataContainerChild child) { this.value.put(child.getIdentifier(), child); return this; } @Override public DataContainerNodeBuilder withNodeIdentifier(I nodeIdentifier) { this.nodeIdentifier = nodeIdentifier; return this; } }