use of com.linkedin.restli.server.annotations.Context in project rest.li by linkedin.
the class RestLiAnnotationReader method buildPagingContextParam.
private static Parameter<?> buildPagingContextParam(final AnnotationSet annotations, final Class<?> paramType, final Class<?> paramAnnotationType) {
if (!paramType.equals(PagingContext.class)) {
throw new ResourceConfigException("Incorrect data type for param: @" + PagingContextParam.class.getSimpleName() + " or @" + Context.class.getSimpleName() + " parameter annotation must be of type " + PagingContext.class.getName());
}
PagingContext defaultContext = null;
Parameter.ParamType parameter = null;
if (paramAnnotationType.equals(PagingContextParam.class)) {
PagingContextParam pagingContextParam = annotations.get(PagingContextParam.class);
defaultContext = new PagingContext(pagingContextParam.defaultStart(), pagingContextParam.defaultCount(), false, false);
parameter = Parameter.ParamType.PAGING_CONTEXT_PARAM;
} else if (paramAnnotationType.equals(Context.class)) {
Context contextParam = annotations.get(Context.class);
defaultContext = new PagingContext(contextParam.defaultStart(), contextParam.defaultCount(), false, false);
parameter = Parameter.ParamType.CONTEXT;
} else {
throw new ResourceConfigException("Param Annotation type must be 'PagingContextParam' or the deprecated 'Context' for PagingContext");
}
Optional optional = annotations.get(Optional.class);
@SuppressWarnings({ "unchecked", "rawtypes" }) Parameter<?> param = new Parameter("", paramType, null, optional != null, defaultContext, parameter, false, annotations);
return param;
}
Aggregations