/** * Setup an example entity. * * @param type The type. * @param example The provided example. * @param <T> The type. * @return The example. */ private <T> Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> prepareExample( Example<T> example, Class<?> type, Class<?>... types) { Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> exampleEntity = new HashMap<>(); InstanceInvocationHandler invocationHandler = new InstanceInvocationHandler( exampleEntity, new ExampleProxyMethodService(type, sessionContext)); List<Class<?>> effectiveTypes = new ArrayList<>(); effectiveTypes.add(type); effectiveTypes.addAll(Arrays.asList(types)); T instance = sessionContext .getProxyFactory() .createInstance( invocationHandler, effectiveTypes.toArray(new Class<?>[effectiveTypes.size()]), CompositeObject.class); example.prepare(instance); return exampleEntity; }