2 * Copyright (c) 2016 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
9 package org.opendaylight.mdsal.binding2.generator.util;
11 import com.google.common.annotations.Beta;
12 import com.google.common.base.Preconditions;
13 import java.util.Objects;
14 import org.opendaylight.mdsal.binding2.model.api.Type;
17 * This class represents ancestor for other <code>Type</code>s
20 abstract public class AbstractBaseType implements Type {
23 * Name of the package to which this <code>Type</code> belongs.
25 private final String packageName;
28 * Name of this <code>Type</code>.
30 private final String name;
33 * Constructs the instance of this class with the concrete package name type
37 * string with the package name to which this <code>Type</code>
40 * string with the name for this <code>Type</code>
42 protected AbstractBaseType(final String pkName, final String name) {
43 this.packageName = Preconditions.checkNotNull(pkName, "Package Name for Generated Type cannot be null!");
44 this.name = Preconditions.checkNotNull(name, "Name of Generated Type cannot be null!");
48 public int hashCode() {
49 return Objects.hash(name, packageName);
53 public boolean equals(final Object obj) {
60 if (getClass() != obj.getClass()) {
63 Type other = (Type) obj;
64 return Objects.equals(this, other);
69 public String toString() {
70 if (packageName.isEmpty()) {
71 return "Type (" + name + ")";
73 return "Type (" + packageName + "." + name + ")";
77 public String getPackageName() {
82 public String getName() {
87 public String getFullyQualifiedName() {
88 if (packageName.isEmpty()) {
91 return packageName + "." + name;