ObjHexStringConverter { public static Object hex2obj(String hexString) throws DecoderException, IOException, ClassNotFoundException { byte[] bytes = Hex.decodeHex(hexString.toCharArray()); ByteArrayInputStream bytesIn = new ByteArrayInputStream(bytes); ObjectInputStream objIn = new ObjectInputStream(bytesIn); Object obj = objIn.readObject(); bytesIn.close(); objIn.close(); return obj; }  static String object2hex(Serializable obj); static Object hex2obj(String hexString);  }
@Test void hex2obj() throws Exception { String intHex = ObjHexStringConverter.object2hex(i); Object objInt = ObjHexStringConverter.hex2obj(intHex); Assertions.assertEquals(i, (Integer) objInt); String objHex = ObjHexStringConverter.object2hex(termId); Object objTermId = ObjHexStringConverter.hex2obj(objHex); Assertions.assertEquals(termId, objTermId); }