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.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;
23 * Utility builder for {@link Bit} instances.
25 * @author Robert Varga
28 public final class BitBuilder implements Builder<Bit>, Mutable {
29 private final String name;
30 private final Uint32 position;
32 private ImmutableList<UnknownSchemaNode> unknownSchemaNodes = ImmutableList.of();
33 private Status status = Status.CURRENT;
34 private String description;
35 private String reference;
37 private BitBuilder(final String name, final Uint32 position) {
38 this.name = requireNonNull(name);
39 this.position = requireNonNull(position);
42 public static BitBuilder create(final String name, final Uint32 position) {
43 return new BitBuilder(name, position);
46 public BitBuilder setDescription(final String description) {
47 this.description = description;
51 public BitBuilder setReference(final String reference) {
52 this.reference = reference;
56 public BitBuilder setStatus(final Status status) {
57 this.status = requireNonNull(status);
61 public BitBuilder setUnknownSchemaNodes(final Collection<UnknownSchemaNode> unknownSchemaNodes) {
62 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
66 public BitBuilder setUnknownSchemaNodes(final UnknownSchemaNode... unknownSchemaNodes) {
67 this.unknownSchemaNodes = ImmutableList.copyOf(unknownSchemaNodes);
73 return new BitImpl(name, position, description, reference, status, unknownSchemaNodes);