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.binding.generator.util;
10 import java.util.Objects;
11 import org.opendaylight.yangtools.sal.binding.model.api.Type;
14 * It is used only as ancestor for other <code>Type</code>s
17 public class AbstractBaseType implements Type {
20 * Name of the package to which this <code>Type</code> belongs.
22 private final String packageName;
25 * Name of this <code>Type</code>.
27 private final String name;
30 public String getPackageName() {
35 public String getName() {
40 public String getFullyQualifiedName() {
41 if (packageName.isEmpty()) {
44 return packageName + "." + name;
49 * Constructs the instance of this class with the concrete package name type
53 * string with the package name to which this <code>Type</code>
56 * string with the name for this <code>Type</code>
58 protected AbstractBaseType(String pkName, String name) {
60 throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
63 throw new IllegalArgumentException("Name of Generated Type cannot be null!");
65 this.packageName = pkName;
70 public int hashCode() {
73 result = prime * result + Objects.hashCode(name);
74 result = prime * result + Objects.hashCode(packageName);
79 public boolean equals(Object obj) {
86 if (!(obj instanceof Type)) {
89 Type other = (Type) obj;
91 if (other.getName() != null) {
94 } else if (!name.equals(other.getName())) {
97 if (packageName == null) {
98 if (other.getPackageName() != null) {
101 } else if (!packageName.equals(other.getPackageName())) {
108 public String toString() {
109 if (packageName.isEmpty()) {
110 return "Type (" + name + ")";
112 return "Type (" + packageName + "." + name + ")";