Move NormalizedNode builders
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / NormalizedNodeResultBuilder.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.util.Collection;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder;
17 import org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeContainerBuilder;
18
19 @SuppressWarnings("rawtypes")
20 final class NormalizedNodeResultBuilder implements NormalizedNodeContainerBuilder {
21     private final @NonNull NormalizedNodeResult result;
22
23     NormalizedNodeResultBuilder() {
24         this.result = new NormalizedNodeResult();
25     }
26
27     NormalizedNodeResultBuilder(final NormalizedNodeResult result) {
28         this.result = requireNonNull(result);
29     }
30
31     @NonNull NormalizedNodeResult result() {
32         return result;
33     }
34
35     @Override
36     public NormalizedNodeBuilder withValue(final Object value) {
37         throw new UnsupportedOperationException();
38     }
39
40     @Override
41     public NormalizedNodeContainerBuilder withValue(final Collection value) {
42         throw new UnsupportedOperationException();
43     }
44
45     @Override
46     public NormalizedNode build() {
47         throw new IllegalStateException("Can not close NormalizedNodeResult");
48     }
49
50     @Override
51     public NormalizedNodeContainerBuilder withNodeIdentifier(final PathArgument nodeIdentifier) {
52         throw new UnsupportedOperationException();
53     }
54
55     @Override
56     public NormalizedNodeContainerBuilder addChild(final NormalizedNode child) {
57         result.setResult(child);
58         return this;
59     }
60
61     @Override
62     public NormalizedNodeContainerBuilder removeChild(final PathArgument key) {
63         throw new UnsupportedOperationException();
64     }
65 }