Populate data/ hierarchy
[yangtools.git] / model / yang-model-ri / src / main / java / org / opendaylight / yangtools / yang / model / ri / type / BitBuilder.java
1 /*
2  * Copyright (c) 2016 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.model.ri.type;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.collect.ImmutableList;
14 import java.util.Collection;
15 import org.opendaylight.yangtools.concepts.Builder;
16 import org.opendaylight.yangtools.concepts.Mutable;
17 import org.opendaylight.yangtools.yang.common.Uint32;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
21
22 /**
23  * Utility builder for {@link Bit} instances.
24  *
25  * @author Robert Varga
26  */
27 @Beta
28 public final class BitBuilder implements Builder<Bit>, Mutable {
29     private final String name;
30     private final Uint32 position;
31
32     private ImmutableList<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.of();
33     private Status status = Status.CURRENT;
34     private String description;
35     private String reference;
36
37     private BitBuilder(final String name, final Uint32 position) {
38         this.name = requireNonNull(name);
39         this.position = requireNonNull(position);
40     }
41
42     public static BitBuilder create(final String name, final Uint32 position) {
43         return new BitBuilder(name, position);
44     }
45
46     public BitBuilder setDescription(final String description) {
47         this.description = description;
48         return this;
49     }
50
51     public BitBuilder setReference(final String reference) {
52         this.reference = reference;
53         return this;
54     }
55
56     public BitBuilder setStatus(final Status status) {
57         this.status = requireNonNull(status);
58         return this;
59     }
60
61     public BitBuilder setUnknownSchemaNodes(final Collection<UnknownSchemaNode> unknownSchemaNodes) {
62         this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
63         return this;
64     }
65
66     public BitBuilder setUnknownSchemaNodes(final UnknownSchemaNode... unknownSchemaNodes) {
67         this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
68         return this;
69     }
70
71     @Override
72     public Bit build() {
73         return new BitImpl(name, position, description, reference, status, unknownSchemaNodes);
74     }
75 }