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 org.opendaylight.yangtools.sal.binding.model.api.Type;
13 * It is used only as ancestor for other <code>Type</code>s
16 public class AbstractBaseType implements Type {
19 * Name of the package to which this <code>Type</code> belongs.
21 private final String packageName;
24 * Name of this <code>Type</code>.
26 private final String name;
29 public String getPackageName() {
34 public String getName() {
39 public String getFullyQualifiedName() {
40 if (packageName.isEmpty()) {
43 return packageName + "." + name;
48 * Constructs the instance of this class with the concrete package name type
52 * string with the package name to which this <code>Type</code>
55 * string with the name for this <code>Type</code>
57 protected AbstractBaseType(String pkName, String name) {
59 throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
62 throw new IllegalArgumentException("Name of Generated Type cannot be null!");
64 this.packageName = pkName;
69 public int hashCode() {
72 result = prime * result + ((name == null) ? 0 : name.hashCode());
73 result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
78 public boolean equals(Object obj) {
85 if (false ==(obj instanceof Type)) {
88 Type other = (Type) obj;
90 if (other.getName() != null) {
93 } else if (!name.equals(other.getName())) {
96 if (packageName == null) {
97 if (other.getPackageName() != null) {
100 } else if (!packageName.equals(other.getPackageName())) {
107 public String toString() {
108 if (packageName.isEmpty()) {
109 return "Type (" + name + ")";
111 return "Type (" + packageName + "." + name + ")";