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.LeafSetEntryNode;
12 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
13 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
15 import com.google.common.base.Preconditions;
17 public final class ImmutableLeafSetNodeSchemaAwareBuilder<T> extends ImmutableLeafSetNodeBuilder<T> {
19 private final LeafListSchemaNode schema;
21 private ImmutableLeafSetNodeSchemaAwareBuilder(LeafListSchemaNode schema) {
24 super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName()));
27 public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(LeafListSchemaNode schema) {
28 return new ImmutableLeafSetNodeSchemaAwareBuilder<>(schema);
32 public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(T value) {
33 // TODO check value type
34 return super.withChildValue(value);
38 public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(LeafSetEntryNode<T> child) {
39 Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()),
40 "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType());
41 return super.withChild(child);
45 public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(InstanceIdentifier.NodeIdentifier nodeIdentifier) {
46 throw new UnsupportedOperationException("Node identifier created from schema");