2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.ri.type;
10 import static java.util.Objects.requireNonNull;
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;
22 * Utility builder for {@link EnumPair} instances.
24 * @author Robert Varga
27 public final class EnumPairBuilder implements Builder<EnumPair>, Mutable {
28 private final String name;
29 private final Integer value;
31 private ImmutableList<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.of();
32 private Status status = Status.CURRENT;
33 private String description;
34 private String reference;
36 private EnumPairBuilder(final String name, final Integer value) {
37 this.name = requireNonNull(name);
38 this.value = requireNonNull(value);
41 public static EnumPairBuilder create(final String name, final Integer value) {
42 return new EnumPairBuilder(name, value);
45 public EnumPairBuilder setDescription(final String description) {
46 this.description = description;
50 public EnumPairBuilder setReference(final String reference) {
51 this.reference = reference;
55 public EnumPairBuilder setStatus(final Status status) {
56 this.status = requireNonNull(status);
60 public EnumPairBuilder setUnknownSchemaNodes(final Collection<? extends UnknownSchemaNode> unknownSchemaNodes) {
61 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
65 public EnumPairBuilder setUnknownSchemaNodes(final UnknownSchemaNode... unknownSchemaNodes) {
66 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
71 public EnumPair build() {
72 return new EnumPairImpl(name, value, description, reference, status, unknownSchemaNodes);