2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.builder.impl;
10 import com.google.common.base.Optional;
11 import com.google.common.collect.ImmutableList;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
15 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.Status;
19 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22 final class LeafSchemaNodeImpl implements LeafSchemaNode, DerivableSchemaNode {
23 private final QName qname;
24 private final SchemaPath path;
30 LeafSchemaNode original;
31 boolean configuration;
32 ConstraintDefinition constraintsDef;
33 TypeDefinition<?> type;
34 ImmutableList<UnknownSchemaNode> unknownNodes;
38 LeafSchemaNodeImpl(final QName qname, final SchemaPath path) {
44 public QName getQName() {
49 public SchemaPath getPath() {
54 public String getDescription() {
59 public String getReference() {
64 public Status getStatus() {
69 public boolean isAugmenting() {
74 public boolean isAddedByUses() {
79 public Optional<LeafSchemaNode> getOriginal() {
80 return Optional.fromNullable(original);
84 public boolean isConfiguration() {
89 public ConstraintDefinition getConstraints() {
90 return constraintsDef;
94 public TypeDefinition<?> getType() {
99 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
104 public String getDefault() {
109 public String getUnits() {
114 public int hashCode() {
115 final int prime = 31;
117 result = prime * result + ((qname == null) ? 0 : qname.hashCode());
118 result = prime * result + ((path == null) ? 0 : path.hashCode());
123 public boolean equals(final Object obj) {
130 if (getClass() != obj.getClass()) {
133 LeafSchemaNodeImpl other = (LeafSchemaNodeImpl) obj;
135 if (other.qname != null) {
138 } else if (!qname.equals(other.qname)) {
142 if (other.path != null) {
145 } else if (!path.equals(other.path)) {
152 public String toString() {
153 StringBuilder sb = new StringBuilder(LeafSchemaNodeImpl.class.getSimpleName());
155 sb.append("qname=").append(qname);
156 sb.append(", path=").append(path);
158 return sb.toString();