TypeUtils { public static byte convertHexDigit(byte c) { byte b = (byte) ((c & 0x1f) + ((c >> 6) * 0x19) - 0x10); if (b < 0 || b > 15) throw new NumberFormatException("!hex " + c); return b; }  static List<T> asList(T[] a); static Class<?> fromName(String name); static String toName(Class<?> type); static Object valueOf(Class<?> type, String value); static Object valueOf(String type, String value); static int parseInt(String s, int offset, int length, int base); static int parseInt(byte[] b, int offset, int length, int base); static byte[] parseBytes(String s, int base); static String toString(byte[] bytes, int base); static byte convertHexDigit(byte c); static int convertHexDigit(char c); static int convertHexDigit(int c); static void toHex(byte b, Appendable buf); static void toHex(int value, Appendable buf); static void toHex(long value, Appendable buf); static String toHexString(byte b); static String toHexString(byte[] b); static String toHexString(byte[] b, int offset, int length); static byte[] fromHexString(String s); static void dump(Class<?> c); static void dump(ClassLoader cl); static boolean isTrue(Object o); static boolean isFalse(Object o); static final Class<?>[] NO_ARGS; static final int CR; static final int LF; }
@Test void convertHexDigitTest() { assertEquals((byte) 0, TypeUtils.convertHexDigit((byte) '0')); assertEquals((byte) 9, TypeUtils.convertHexDigit((byte) '9')); assertEquals((byte) 10, TypeUtils.convertHexDigit((byte) 'a')); assertEquals((byte) 10, TypeUtils.convertHexDigit((byte) 'A')); assertEquals((byte) 15, TypeUtils.convertHexDigit((byte) 'f')); assertEquals((byte) 15, TypeUtils.convertHexDigit((byte) 'F')); assertEquals(0, TypeUtils.convertHexDigit((int) '0')); assertEquals(9, TypeUtils.convertHexDigit((int) '9')); assertEquals(10, TypeUtils.convertHexDigit((int) 'a')); assertEquals(10, TypeUtils.convertHexDigit((int) 'A')); assertEquals(15, TypeUtils.convertHexDigit((int) 'f')); assertEquals(15, TypeUtils.convertHexDigit((int) 'F')); }