1 17 package org.apache.bcel.generic; 18 19 import org.apache.bcel.Constants; 20 21 27 public final class BasicType extends Type { 28 29 35 BasicType(byte type) { 36 super(type, Constants.SHORT_TYPE_NAMES[type]); 37 if ((type < Constants.T_BOOLEAN) || (type > Constants.T_VOID)) { 38 throw new ClassGenException("Invalid type: " + type); 39 } 40 } 41 42 43 public static final BasicType getType( byte type ) { 44 switch (type) { 45 case Constants.T_VOID: 46 return VOID; 47 case Constants.T_BOOLEAN: 48 return BOOLEAN; 49 case Constants.T_BYTE: 50 return BYTE; 51 case Constants.T_SHORT: 52 return SHORT; 53 case Constants.T_CHAR: 54 return CHAR; 55 case Constants.T_INT: 56 return INT; 57 case Constants.T_LONG: 58 return LONG; 59 case Constants.T_DOUBLE: 60 return DOUBLE; 61 case Constants.T_FLOAT: 62 return FLOAT; 63 default: 64 throw new ClassGenException("Invalid type: " + type); 65 } 66 } 67 68 69 71 public int hashCode() { 72 return type; 73 } 74 75 76 78 public boolean equals( Object _type ) { 79 return (_type instanceof BasicType) ? ((BasicType) _type).type == this.type : false; 80 } 81 } 82 | Popular Tags |