Search in sources :

Example 1 with ResourceListBase

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;
}
Also used : DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) ResourceListBase(io.crnk.core.resource.list.ResourceListBase)

Aggregations

DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)1 ResourceListBase (io.crnk.core.resource.list.ResourceListBase)1