2 * Copyright (c) 2015 Pantheon Technologies s.r.o. 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 com.google.common.base.Preconditions.checkState;
12 import com.google.common.collect.ImmutableSet;
13 import com.google.common.collect.ImmutableSet.Builder;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
20 public final class IdentityrefTypeBuilder extends TypeBuilder<IdentityrefTypeDefinition> {
21 private final Builder<IdentitySchemaNode> builder = ImmutableSet.builder();
23 IdentityrefTypeBuilder(final QName qname) {
27 public IdentityrefTypeBuilder addIdentity(final @NonNull IdentitySchemaNode identity) {
28 builder.add(identity);
33 public IdentityrefTypeDefinition build() {
34 final Set<IdentitySchemaNode> identities = builder.build();
35 checkState(!identities.isEmpty(), "No identities specified in %s, at least one is required", getQName());
36 return new BaseIdentityrefType(getQName(), getUnknownSchemaNodes(), identities);