Seed yang-model-spi with model.util.type
[yangtools.git] / yang / yang-model-spi / src / main / java / org / opendaylight / yangtools / yang / model / spi / type / RestrictedInstanceIdentifierType.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.spi.type;
9
10 import java.util.Collection;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
14
15 final class RestrictedInstanceIdentifierType extends AbstractRestrictedType<InstanceIdentifierTypeDefinition>
16         implements InstanceIdentifierTypeDefinition {
17     private final boolean requireInstance;
18
19     RestrictedInstanceIdentifierType(final InstanceIdentifierTypeDefinition baseType, final QName qname,
20             final Collection<? extends UnknownSchemaNode> unknownSchemaNodes, final boolean requireInstance) {
21         super(baseType, qname, unknownSchemaNodes);
22         this.requireInstance = requireInstance;
23     }
24
25     private RestrictedInstanceIdentifierType(final RestrictedInstanceIdentifierType original, final QName qname) {
26         super(original, qname);
27         this.requireInstance = original.requireInstance;
28     }
29
30     @Override
31     RestrictedInstanceIdentifierType bindTo(final QName newQName) {
32         return new RestrictedInstanceIdentifierType(this, newQName);
33     }
34
35     @Override
36     public boolean requireInstance() {
37         return requireInstance;
38     }
39
40     @Override
41     public int hashCode() {
42         return InstanceIdentifierTypeDefinition.hashCode(this);
43     }
44
45     @Override
46     public boolean equals(final Object obj) {
47         return InstanceIdentifierTypeDefinition.equals(this, obj);
48     }
49
50     @Override
51     public String toString() {
52         return InstanceIdentifierTypeDefinition.toString(this);
53     }
54 }