use of io.crnk.core.resource.list.ResourceListBase in project crnk-framework by crnk-project.
the class ClientStubInvocationHandler method createTypesafeList.
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object createTypesafeList(Object result, Class<?> returnType) {
DefaultResourceList defaultList = (DefaultResourceList) result;
Class<?>[] typeArguments = TypeResolver.resolveRawArguments(ResourceListBase.class, returnType);
Class<?> metaType = typeArguments[1];
Class<?> linksType = typeArguments[2];
ResourceListBase typedList = (ResourceListBase) ClassUtils.newInstance(returnType);
typedList.addAll(defaultList);
typedList.setMeta(defaultList.getMeta(metaType));
typedList.setLinks(defaultList.getLinks(linksType));
return typedList;
}
Aggregations