Merge branch 'master' of ../controller
[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 static java.util.Objects.requireNonNull;
11
12 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
13 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
14
15 public final class InstanceIdentifierTypeBuilder
16         extends RequireInstanceRestrictedTypeBuilder<InstanceIdentifierTypeDefinition> {
17
18     InstanceIdentifierTypeBuilder(final InstanceIdentifierTypeDefinition baseType,
19             final SchemaPath path) {
20         super(requireNonNull(baseType), path);
21     }
22
23     @Override
24     InstanceIdentifierTypeDefinition buildType() {
25         final InstanceIdentifierTypeDefinition base = getBaseType();
26         if (getRequireInstance() == base.requireInstance()) {
27             return base;
28         }
29
30         return new RestrictedInstanceIdentifierType(base, getPath(), getUnknownSchemaNodes(), getRequireInstance());
31     }
32 }