Initial opendaylight infrastructure commit!!
[controller.git] / opendaylight / sal / yang-prototype / code-generator / binding-generator-util / src / main / java / org / opendaylight / controller / binding / generator / util / AbstractBaseType.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\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
7  */\r
8 package org.opendaylight.controller.binding.generator.util;\r
9 \r
10 import org.opendaylight.controller.sal.binding.model.api.Type;\r
11 \r
12 public class AbstractBaseType implements Type {\r
13 \r
14     private final String packageName;\r
15     private final String name;\r
16 \r
17     @Override\r
18     public String getPackageName() {\r
19         return packageName;\r
20     }\r
21 \r
22     @Override\r
23     public String getName() {\r
24 \r
25         return name;\r
26     }\r
27 \r
28     protected AbstractBaseType(String pkName, String name) {\r
29         this.packageName = pkName;\r
30         this.name = name;\r
31     }\r
32 \r
33     @Override\r
34     public int hashCode() {\r
35         final int prime = 31;\r
36         int result = 1;\r
37         result = prime * result + ((name == null) ? 0 : name.hashCode());\r
38         result = prime * result\r
39                 + ((packageName == null) ? 0 : packageName.hashCode());\r
40         return result;\r
41     }\r
42 \r
43     @Override\r
44     public boolean equals(Object obj) {\r
45         if (this == obj)\r
46             return true;\r
47         if (obj == null)\r
48             return false;\r
49         if (getClass() != obj.getClass())\r
50             return false;\r
51         Type other = (Type) obj;\r
52         if (name == null) {\r
53             if (other.getName() != null)\r
54                 return false;\r
55         } else if (!name.equals(other.getPackageName()))\r
56             return false;\r
57         if (packageName == null) {\r
58             if (other.getPackageName() != null)\r
59                 return false;\r
60         } else if (!packageName.equals(other.getPackageName()))\r
61             return false;\r
62         return true;\r
63     }\r
64 \r
65     @Override\r
66     public String toString() {\r
67 \r
68         return "Type (" + packageName + "." + name + ")";\r
69     }\r
70 \r
71 }\r