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.util;
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
12 import org.opendaylight.yangtools.yang.model.api.Status;
13 import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
15 import com.google.common.base.Preconditions;
18 * Basic implementation of SchemaNodeBuilder.
20 public abstract class AbstractSchemaNodeBuilder extends AbstractBuilder implements SchemaNodeBuilder {
21 protected final QName qname;
22 protected SchemaPath schemaPath;
23 protected String description;
24 protected String reference;
25 protected Status status = Status.CURRENT;
27 protected AbstractSchemaNodeBuilder(final String moduleName, final int line, final QName qname) {
28 super(moduleName, line);
33 public QName getQName() {
38 public SchemaPath getPath() {
43 public void setPath(final SchemaPath path) {
44 this.schemaPath = path;
48 public String getDescription() {
53 public void setDescription(final String description) {
54 this.description = description;
58 public String getReference() {
63 public void setReference(final String reference) {
64 this.reference = reference;
68 public Status getStatus() {
73 public void setStatus(Status status) {
74 this.status = Preconditions.checkNotNull(status, "status cannot be null");
78 public int hashCode() {
80 int result = super.hashCode();
81 result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
82 result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
87 public boolean equals(Object obj) {
94 if (getClass() != obj.getClass()) {
97 if (!super.equals(obj)) {
100 AbstractSchemaNodeBuilder other = (AbstractSchemaNodeBuilder) obj;
101 if (getParent() == null) {
102 if (other.getParent() != null) {
105 } else if (!getParent().equals(other.getParent())) {
108 if (schemaPath == null) {
109 if (other.schemaPath != null) {
112 } else if (!schemaPath.equals(other.schemaPath)) {