1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.generic;
18
19 import org.apache.bcel.Const;
20
21
22
23
24 public final class BasicType extends Type {
25
26
27 public static BasicType getType(final byte type) {
28 switch (type) {
29 case Const.T_VOID:
30 return VOID;
31 case Const.T_BOOLEAN:
32 return BOOLEAN;
33 case Const.T_BYTE:
34 return BYTE;
35 case Const.T_SHORT:
36 return SHORT;
37 case Const.T_CHAR:
38 return CHAR;
39 case Const.T_INT:
40 return INT;
41 case Const.T_LONG:
42 return LONG;
43 case Const.T_DOUBLE:
44 return DOUBLE;
45 case Const.T_FLOAT:
46 return FLOAT;
47 default:
48 throw new ClassGenException("Invalid type: " + type);
49 }
50 }
51
52
53
54
55
56
57
58 BasicType(final byte type) {
59 super(type, Const.getShortTypeName(type));
60 if (type < Const.T_BOOLEAN || type > Const.T_VOID) {
61 throw new ClassGenException("Invalid type: " + type);
62 }
63 }
64
65
66
67
68 @Override
69 public boolean equals(final Object type) {
70 return type instanceof BasicType && ((BasicType) type).getType() == this.getType();
71 }
72
73
74
75
76 @Override
77 public int hashCode() {
78 return super.getType();
79 }
80 }