assertEquals(f.get("1"), (Integer) 1);
assertEquals(f.get("2"), (Integer) 2);
}
public static void hookTest() throws Exception {
Converter converter = new Converter().hook(File.class, new Hook() {
public Object convert(Type dest, Object o) {
if (o instanceof String) {
return IO.getFile(new File(""), o.toString());
}
return null;
}
});
assertEquals(new Integer(6), converter.convert(Integer.class, "6"));
assertEquals(new File("src").getAbsoluteFile(), converter.convert(File.class, "src"));
converter.hook(null, new Hook() {
public Object convert(Type dest, Object o) throws Exception {
if (dest instanceof Class) {
if (Number.class.isAssignableFrom((Class< ? >) dest))
return 1;