2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.yangtools.binding.generator.util;
\r
10 import org.opendaylight.yangtools.sal.binding.model.api.Type;
\r
13 * It is used only as ancestor for other <code>Type</code>s
\r
16 public class AbstractBaseType implements Type {
\r
19 * Name of the package to which this <code>Type</code> belongs.
\r
21 private final String packageName;
\r
24 * Name of this <code>Type</code>.
\r
26 private final String name;
\r
29 public String getPackageName() {
\r
34 public String getName() {
\r
39 public String getFullyQualifiedName() {
\r
40 if (packageName.isEmpty()) {
\r
43 return packageName + "." + name;
\r
48 * Constructs the instance of this class with the concrete package name type
\r
52 * string with the package name to which this <code>Type</code>
\r
55 * string with the name for this <code>Type</code>
\r
57 protected AbstractBaseType(String pkName, String name) {
\r
58 if (pkName == null) {
\r
59 throw new IllegalArgumentException("Package Name for Generated Type cannot be null!");
\r
62 throw new IllegalArgumentException("Name of Generated Type cannot be null!");
\r
64 this.packageName = pkName;
\r
69 public int hashCode() {
\r
70 final int prime = 31;
\r
72 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
73 result = prime * result + ((packageName == null) ? 0 : packageName.hashCode());
\r
78 public boolean equals(Object obj) {
\r
83 if (getClass() != obj.getClass())
\r
85 Type other = (Type) obj;
\r
87 if (other.getName() != null)
\r
89 } else if (!name.equals(other.getName()))
\r
91 if (packageName == null) {
\r
92 if (other.getPackageName() != null)
\r
94 } else if (!packageName.equals(other.getPackageName()))
\r
100 public String toString() {
\r
101 if (packageName.isEmpty()) {
\r
102 return "Type (" + name + ")";
\r
104 return "Type (" + packageName + "." + name + ")";
\r