Deprecate schema-aware builders
[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 static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
14 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
16 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
17
18 @Deprecated(since = "6.0.7", forRemoval = true)
19 public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends ImmutableLeafSetEntryNodeBuilder<T> {
20     private final LeafListSchemaNode schema;
21
22     private ImmutableLeafSetEntryNodeSchemaAwareBuilder(final LeafListSchemaNode schema) {
23         this.schema = requireNonNull(schema);
24     }
25
26     public static <T> @NonNull NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(
27             final LeafListSchemaNode schema) {
28         return new ImmutableLeafSetEntryNodeSchemaAwareBuilder<>(schema);
29     }
30
31     @Override
32     public NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withValue(final T withValue) {
33         super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), withValue));
34         // TODO check value type using TypeProvider ?
35         return super.withValue(withValue);
36     }
37
38     @Override
39     public NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(
40             final NodeWithValue withNodeIdentifier) {
41         throw new UnsupportedOperationException("Node identifier created from schema");
42     }
43 }