Immutable implementation of new yang-data-api
[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 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.NormalizedNodeBuilder;
13 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
14
15 public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends ImmutableLeafSetEntryNodeBuilder<T> {
16
17     private final LeafListSchemaNode schema;
18
19     private ImmutableLeafSetEntryNodeSchemaAwareBuilder(LeafListSchemaNode schema) {
20         super();
21         this.schema = schema;
22     }
23
24     public static <T> NormalizedNodeBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> create(LeafListSchemaNode schema) {
25         return new ImmutableLeafSetEntryNodeSchemaAwareBuilder<>(schema);
26     }
27
28     @Override
29     public NormalizedNodeBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> withValue(T value) {
30         super.withNodeIdentifier(new InstanceIdentifier.NodeWithValue(schema.getQName(), value));
31         // TODO check value type
32         return super.withValue(value);
33     }
34
35     @Override
36     public NormalizedNodeBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(InstanceIdentifier.NodeWithValue nodeIdentifier) {
37         throw new UnsupportedOperationException("Node identifier created from schema");
38     }
39
40 }