@Test public void createsProxyObjectForInterface() { IBook book = JsonUtils.createProxy(IBook.class); assertNotNull(book); assertEquals(null, book.getAuthor()); assertEquals(null, book.getTitle()); assertEquals(0, book.getPages()); assertEquals(0.0, book.getPrice(), 0.01); assertEquals(0L, book.getIsdn()); assertEquals(false, book.getAvailability()); assertEquals(false, book.getDelivery()); book.setAuthor("Vincent Massol"); book.setTitle("JUnit in Action"); book.setPages(386); book.setPrice(19.37); book.setIsdn(93011099534534L); book.setAvailability(true); book.setDelivery(false); assertEquals("Vincent Massol", book.getAuthor()); assertEquals("JUnit in Action", book.getTitle()); assertEquals(386, book.getPages()); assertEquals(19.37, book.getPrice(), 0.01); assertEquals(93011099534534L, book.getIsdn()); assertEquals(true, book.getAvailability()); assertEquals(false, book.getDelivery()); assertNotNull(book.toString()); }
@SuppressWarnings({"unchecked"}) public static <T> T createProxy(Class<T> anInterface) { if (anInterface == null) { throw new IllegalArgumentException(); } if (anInterface.isInterface()) { return (T)Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, new ProxyObject(anInterface)); } throw new IllegalArgumentException(String.format("Type '%s' is not interface. ", anInterface.getSimpleName())); }
JsonUtils { @SuppressWarnings({"unchecked"}) public static <T> T createProxy(Class<T> anInterface) { if (anInterface == null) { throw new IllegalArgumentException(); } if (anInterface.isInterface()) { return (T)Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, new ProxyObject(anInterface)); } throw new IllegalArgumentException(String.format("Type '%s' is not interface. ", anInterface.getSimpleName())); } }
JsonUtils { @SuppressWarnings({"unchecked"}) public static <T> T createProxy(Class<T> anInterface) { if (anInterface == null) { throw new IllegalArgumentException(); } if (anInterface.isInterface()) { return (T)Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, new ProxyObject(anInterface)); } throw new IllegalArgumentException(String.format("Type '%s' is not interface. ", anInterface.getSimpleName())); } private  JsonUtils(); }
JsonUtils { @SuppressWarnings({"unchecked"}) public static <T> T createProxy(Class<T> anInterface) { if (anInterface == null) { throw new IllegalArgumentException(); } if (anInterface.isInterface()) { return (T)Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, new ProxyObject(anInterface)); } throw new IllegalArgumentException(String.format("Type '%s' is not interface. ", anInterface.getSimpleName())); } private  JsonUtils(); static String getJsonString(String string); static boolean isKnownType(Class<?> clazz); static Types getType(Object o); static Types getType(Class<?> clazz); static Set<String> getTransientFields(Class<?> aClass); @SuppressWarnings({"unchecked"}) static T createProxy(Class<T> anInterface); }
JsonUtils { @SuppressWarnings({"unchecked"}) public static <T> T createProxy(Class<T> anInterface) { if (anInterface == null) { throw new IllegalArgumentException(); } if (anInterface.isInterface()) { return (T)Proxy.newProxyInstance(anInterface.getClassLoader(), new Class[]{anInterface}, new ProxyObject(anInterface)); } throw new IllegalArgumentException(String.format("Type '%s' is not interface. ", anInterface.getSimpleName())); } private  JsonUtils(); static String getJsonString(String string); static boolean isKnownType(Class<?> clazz); static Types getType(Object o); static Types getType(Class<?> clazz); static Set<String> getTransientFields(Class<?> aClass); @SuppressWarnings({"unchecked"}) static T createProxy(Class<T> anInterface);  }