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 java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
16 import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.Status;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
23 final class LeafSchemaNodeImpl implements LeafSchemaNode, DerivableSchemaNode {
24 private final QName qname;
25 private final SchemaPath path;
31 LeafSchemaNode original;
32 boolean configuration;
33 ConstraintDefinition constraintsDef;
34 TypeDefinition<?> type;
35 ImmutableList<UnknownSchemaNode> unknownNodes;
39 LeafSchemaNodeImpl(final QName qname, final SchemaPath path) {
45 public QName getQName() {
50 public SchemaPath getPath() {
55 public String getDescription() {
60 public String getReference() {
65 public Status getStatus() {
70 public boolean isAugmenting() {
75 public boolean isAddedByUses() {
80 public Optional<LeafSchemaNode> getOriginal() {
81 return Optional.fromNullable(original);
85 public boolean isConfiguration() {
90 public ConstraintDefinition getConstraints() {
91 return constraintsDef;
95 public TypeDefinition<?> getType() {
100 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
105 public String getDefault() {
110 public String getUnits() {
115 public int hashCode() {
116 final int prime = 31;
118 result = prime * result + Objects.hashCode(qname);
119 result = prime * result + Objects.hashCode(path);
124 public boolean equals(final Object obj) {
131 if (getClass() != obj.getClass()) {
134 LeafSchemaNodeImpl other = (LeafSchemaNodeImpl) obj;
136 if (other.qname != null) {
139 } else if (!qname.equals(other.qname)) {
143 if (other.path != null) {
146 } else if (!path.equals(other.path)) {
153 public String toString() {
154 StringBuilder sb = new StringBuilder(LeafSchemaNodeImpl.class.getSimpleName());
156 sb.append("qname=").append(qname);
157 sb.append(", path=").append(path);
159 return sb.toString();