Import YangInstanceIdentifier inner classes
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableLeafSetEntryNodeSchemaAwareBuilder.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
12 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
13 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
14 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
15
16 public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends ImmutableLeafSetEntryNodeBuilder<T> {
17
18     private final LeafListSchemaNode schema;
19
20     private ImmutableLeafSetEntryNodeSchemaAwareBuilder(final LeafListSchemaNode schema) {
21         this.schema = Preconditions.checkNotNull(schema);
22     }
23
24     public static <T> NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(final LeafListSchemaNode schema) {
25         return new ImmutableLeafSetEntryNodeSchemaAwareBuilder<>(schema);
26     }
27
28     @Override
29     public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withValue(final T value) {
30         super.withNodeIdentifier(new NodeWithValue(schema.getQName(), value));
31         // TODO check value type using TypeProvider ?
32         return super.withValue(value);
33     }
34
35     @Override
36     public NormalizedNodeAttrBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(final NodeWithValue nodeIdentifier) {
37         throw new UnsupportedOperationException("Node identifier created from schema");
38     }
39
40 }