ModelAdapterUtil { public static <T> List<T> adapt(Class<T> clazz, List<?> delegateObjects) { List<T> adaptedObjects = new ArrayList<>(delegateObjects.size()); for (Object delegateObject : delegateObjects) { adaptedObjects.add(adapt(clazz, delegateObject)); } return adaptedObjects; }  static List<T> adapt(Class<T> clazz, List<?> delegateObjects); static T adapt(Class<T> clazz, Object delegateObject); static T[] adapt(Class<T> clazz, Object[] delegateObjects); static Comparator<T> adapt(
		Class<V> clazz, Comparator<V> comparator); static OrderByComparator<T> adapt(
		Class<V> clazz, OrderByComparator<V> orderByComparator); static QueryDefinition<T> adapt(
		Class<V> clazz, QueryDefinition<V> queryDefinition); static T adapt(
		Function<InvocationHandler, T> proxyProviderFunction,
		Object delegateObject);  }
@Test public void testAdapt() { Assert.assertEquals( ModelAdapterUtil.adapt(TestInterface.class, new TestClass(1)), new TestClass(1)); Assert.assertEquals( ModelAdapterUtil.adapt(TestInterface.class, new TestClass(1)), ModelAdapterUtil.adapt(TestInterface.class, new TestClass(1))); TestInterface proxyObject = ModelAdapterUtil.adapt( TestInterface.class, new TestClass(1)); Assert.assertEquals(0, proxyObject.compareTo(new TestClass(1))); Assert.assertEquals(-1, proxyObject.compareTo(new TestClass(2))); Assert.assertEquals(1, proxyObject.compareTo(new TestClass(0))); Assert.assertEquals( 0, proxyObject.compareTo( ModelAdapterUtil.adapt(TestInterface.class, new TestClass(1)))); Assert.assertEquals( -1, proxyObject.compareTo( ModelAdapterUtil.adapt(TestInterface.class, new TestClass(2)))); Assert.assertEquals( 1, proxyObject.compareTo( ModelAdapterUtil.adapt(TestInterface.class, new TestClass(0)))); }