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