Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / RestrictedLeafrefType.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 java.util.Collection;
11 import org.opendaylight.yangtools.yang.model.api.PathExpression;
12 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
13 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
15
16 final class RestrictedLeafrefType extends AbstractRestrictedType<LeafrefTypeDefinition>
17         implements LeafrefTypeDefinition {
18
19     private final boolean requireInstance;
20
21     RestrictedLeafrefType(final LeafrefTypeDefinition baseType, final SchemaPath path,
22             final Collection<UnknownSchemaNode> unknownSchemaNodes, final boolean requireInstance) {
23         super(baseType, path, unknownSchemaNodes);
24
25         this.requireInstance = requireInstance;
26     }
27
28     @Override
29     public PathExpression getPathStatement() {
30         return getBaseType().getPathStatement();
31     }
32
33     @Override
34     public boolean requireInstance() {
35         return requireInstance;
36     }
37
38     @Override
39     public int hashCode() {
40         return LeafrefTypeDefinition.hashCode(this);
41     }
42
43     @Override
44     public boolean equals(final Object obj) {
45         return LeafrefTypeDefinition.equals(this, obj);
46     }
47
48     @Override
49     public String toString() {
50         return LeafrefTypeDefinition.toString(this);
51     }
52 }