Move TypeDefinitions into yang-model-api
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / InstanceIdentifierTypeBuilder.java
1 /*
2  * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.util.type;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
12 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
13
14 public final class InstanceIdentifierTypeBuilder
15         extends RequireInstanceRestrictedTypeBuilder<InstanceIdentifierTypeDefinition> {
16
17     InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType,
18             final SchemaPath path) {
19         super(Preconditions.checkNotNull(baseType), path);
20     }
21
22     @Override
23     InstanceIdentifierTypeDefinition buildType() {
24         if (getRequireInstance() == getBaseType().requireInstance()) {
25             return getBaseType();
26         }
27
28         return new RestrictedInstanceIdentifierType(getBaseType(), getPath(), getUnknownSchemaNodes(),
29                 getRequireInstance());
30     }
31 }