Populate model/ hierarchy
[yangtools.git] / model / yang-model-ri / src / main / java / org / opendaylight / yangtools / yang / model / ri / type / EnumPairBuilder.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.model.api.Status;
18 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
20
21 /**
22  * Utility builder for {@link EnumPair} instances.
23  *
24  * @author Robert Varga
25  */
26 @Beta
27 public final class EnumPairBuilder implements Builder<EnumPair>, Mutable {
28     private final String name;
29     private final Integer value;
30
31     private ImmutableList<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.of();
32     private Status status = Status.CURRENT;
33     private String description;
34     private String reference;
35
36     private EnumPairBuilder(final String name, final Integer value) {
37         this.name = requireNonNull(name);
38         this.value = requireNonNull(value);
39     }
40
41     public static EnumPairBuilder create(final String name, final Integer value) {
42         return new EnumPairBuilder(name, value);
43     }
44
45     public EnumPairBuilder setDescription(final String description) {
46         this.description = description;
47         return this;
48     }
49
50     public EnumPairBuilder setReference(final String reference) {
51         this.reference = reference;
52         return this;
53     }
54
55     public EnumPairBuilder setStatus(final Status status) {
56         this.status = requireNonNull(status);
57         return this;
58     }
59
60     public EnumPairBuilder setUnknownSchemaNodes(final Collection<? extends UnknownSchemaNode> unknownSchemaNodes) {
61         this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
62         return this;
63     }
64
65     public EnumPairBuilder setUnknownSchemaNodes(final UnknownSchemaNode... unknownSchemaNodes) {
66         this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
67         return this;
68     }
69
70     @Override
71     public EnumPair build() {
72         return new EnumPairImpl(name, value, description, reference, status, unknownSchemaNodes);
73     }
74 }