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.builder.impl;
10 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
11 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
12 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
13 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
14 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
16 import com.google.common.base.Preconditions;
18 public class ImmutableMapNodeSchemaAwareBuilder extends ImmutableMapNodeBuilder {
20 private final ListSchemaNode schema;
22 protected ImmutableMapNodeSchemaAwareBuilder(ListSchemaNode schema) {
25 super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName()));
28 public static CollectionNodeBuilder<MapEntryNode, MapNode> create(ListSchemaNode schema) {
29 return new ImmutableMapNodeSchemaAwareBuilder(schema);
33 public CollectionNodeBuilder<MapEntryNode, MapNode> withChild(MapEntryNode child) {
34 Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()),
35 "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType());
36 return super.withChild(child);
40 public CollectionNodeBuilder<MapEntryNode, MapNode> withNodeIdentifier(InstanceIdentifier.NodeIdentifier nodeIdentifier) {
41 throw new UnsupportedOperationException("Node identifier created from schema");