2 * Copyright (c) 2017 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.binding.javav2.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.binding.javav2.model.api.Type;
17 * This class represents ancestor for other <code>Type</code>s
20 public abstract class AbstractBaseType implements Type {
23 * Name of the package to which this <code>Type</code> belongs.
25 protected final String packageName;
28 * Name of this <code>Type</code>.
30 protected 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(this.name, this.packageName);
53 public boolean equals(final Object obj) {
60 if (!(obj instanceof Type)) {
63 final Type other = (Type) obj;
64 return Objects.equals(this.name, other.getName()) && Objects.equals(this.packageName, other.getPackageName());
69 public String toString() {
70 if (this.packageName.isEmpty()) {
71 return "Type (" + this.name + ")";
73 return "Type (" + this.packageName + "." + this.name + ")";
77 public String getPackageName() {
78 return this.packageName;
82 public String getName() {
87 public String getFullyQualifiedName() {
88 if (this.packageName.isEmpty()) {
91 return this.packageName + "." + this.name;