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) {
22 this.schema = Preconditions.checkNotNull(schema);
23 super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName()));
26 public static <T> ListNodeBuilder<T, LeafSetEntryNode<T>> create(LeafListSchemaNode schema) {
27 return new ImmutableLeafSetNodeSchemaAwareBuilder<>(schema);
31 public ListNodeBuilder<T, LeafSetEntryNode<T>> withChildValue(T value) {
32 // TODO check value type
33 return super.withChildValue(value);
37 public ListNodeBuilder<T, LeafSetEntryNode<T>> withChild(LeafSetEntryNode<T> child) {
38 Preconditions.checkArgument(schema.getQName().equals(child.getNodeType()),
39 "Incompatible node type, should be: %s, is: %s", schema.getQName(), child.getNodeType());
40 return super.withChild(child);
44 public ListNodeBuilder<T, LeafSetEntryNode<T>> withNodeIdentifier(InstanceIdentifier.NodeIdentifier nodeIdentifier) {
45 throw new UnsupportedOperationException("Node identifier created from schema");