Advertisement
TheReturningVoid

Untitled

Sep 17th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public enum DataType {
  2.     BYTE(byte.class, Byte.class),
  3.     SHORT(short.class, Short.class),
  4.     INTEGER(int.class, Integer.class),
  5.     LONG(long.class, Long.class),
  6.     CHARACTER(char.class, Character.class),
  7.     FLOAT(float.class, Float.class),
  8.     DOUBLE(double.class, Double.class),
  9.     BOOLEAN(boolean.class, Boolean.class);
  10.  
  11.     private static final Map<Class<?>, DataType> CLASS_MAP = new HashMap<Class<?>, DataType>();
  12.     private final Class<?> primitive;
  13.     private final Class<?> reference;
  14.  
  15.     // Initialize map for quick class lookup
  16.     static {
  17.         for (DataType type : values()) {
  18.             CLASS_MAP.put(type.primitive, type);
  19.             CLASS_MAP.put(type.reference, type);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement