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.api;
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;
14 import com.google.common.base.Preconditions;
17 * Basic implementation of SchemaNodeBuilder.
19 public abstract class AbstractSchemaNodeBuilder extends AbstractBuilder implements SchemaNodeBuilder {
20 protected final QName qname;
21 protected SchemaPath schemaPath;
22 protected String description;
23 protected String reference;
24 protected Status status = Status.CURRENT;
26 protected AbstractSchemaNodeBuilder(final String moduleName, final int line, final QName qname) {
27 super(moduleName, line);
32 public QName getQName() {
37 public SchemaPath getPath() {
42 public void setPath(final SchemaPath path) {
43 this.schemaPath = path;
47 public String getDescription() {
52 public void setDescription(final String description) {
53 this.description = description;
57 public String getReference() {
62 public void setReference(final String reference) {
63 this.reference = reference;
67 public Status getStatus() {
72 public void setStatus(Status status) {
73 this.status = Preconditions.checkNotNull(status, "status cannot be null");
77 public int hashCode() {
79 int result = super.hashCode();
80 result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
81 result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
86 public boolean equals(Object obj) {
93 if (getClass() != obj.getClass()) {
96 if (!super.equals(obj)) {
99 AbstractSchemaNodeBuilder other = (AbstractSchemaNodeBuilder) obj;
100 if (getParent() == null) {
101 if (other.getParent() != null) {
104 } else if (!getParent().equals(other.getParent())) {
107 if (schemaPath == null) {
108 if (other.schemaPath != null) {
111 } else if (!schemaPath.equals(other.schemaPath)) {