Search in sources :

Example 6 with Optional

use of com.linkedin.restli.server.annotations.Optional in project rest.li by linkedin.

the class RestLiAnnotationReader method buildProjectionParam.

private static Parameter<?> buildProjectionParam(final AnnotationSet annotations, final Class<?> paramType, final Parameter.ParamType projectionType) {
    if (!paramType.equals(MaskTree.class)) {
        throw new ResourceConfigException("Incorrect data type for param: @" + ProjectionParam.class.getSimpleName() + ", @" + Projection.class.getSimpleName() + ", @" + MetadataProjectionParam.class.getSimpleName() + " or @" + PagingProjectionParam.class.getSimpleName() + " parameter annotation must be of type " + MaskTree.class.getName());
    }
    Optional optional = annotations.get(Optional.class);
    @SuppressWarnings({ "unchecked", "rawtypes" }) Parameter<?> param = new Parameter("", paramType, null, optional != null, // default mask is null.
    null, projectionType, false, annotations);
    return param;
}
Also used : Optional(com.linkedin.restli.server.annotations.Optional) MaskTree(com.linkedin.data.transform.filter.request.MaskTree) ResourceConfigException(com.linkedin.restli.server.ResourceConfigException)

Example 7 with Optional

use of com.linkedin.restli.server.annotations.Optional in project rest.li by linkedin.

the class RestLiAnnotationReader method buildPathKeysParam.

private static Parameter<?> buildPathKeysParam(final AnnotationSet annotations, final Class<?> paramType, final Class<?> paramAnnotationType) {
    if (!paramType.equals(PathKeys.class)) {
        throw new ResourceConfigException("Incorrect data type for param: @" + PathKeysParam.class.getSimpleName() + " or @" + Keys.class.getSimpleName() + " parameter annotation must be of type " + PathKeys.class.getName());
    }
    Optional optional = annotations.get(Optional.class);
    Parameter.ParamType parameter = null;
    if (paramAnnotationType.equals(Keys.class)) {
        parameter = Parameter.ParamType.PATH_KEYS;
    } else if (paramAnnotationType.equals(PathKeysParam.class)) {
        parameter = Parameter.ParamType.PATH_KEYS_PARAM;
    } else {
        throw new ResourceConfigException("Param Annotation type must be 'PathKeysParam' or the deprecated 'Keys' for PathKeys");
    }
    @SuppressWarnings({ "unchecked", "rawtypes" }) Parameter<?> param = new Parameter("", paramType, null, optional != null, new PathKeysImpl(), parameter, false, annotations);
    return param;
}
Also used : PathKeys(com.linkedin.restli.server.PathKeys) Optional(com.linkedin.restli.server.annotations.Optional) PathKeysParam(com.linkedin.restli.server.annotations.PathKeysParam) PathKeysImpl(com.linkedin.restli.internal.server.PathKeysImpl) ResourceConfigException(com.linkedin.restli.server.ResourceConfigException)

Aggregations

ResourceConfigException (com.linkedin.restli.server.ResourceConfigException)7 Optional (com.linkedin.restli.server.annotations.Optional)7 TemplateRuntimeException (com.linkedin.data.template.TemplateRuntimeException)3 RestLiInternalException (com.linkedin.restli.internal.server.RestLiInternalException)3 MaskTree (com.linkedin.data.transform.filter.request.MaskTree)1 PathKeysImpl (com.linkedin.restli.internal.server.PathKeysImpl)1 PagingContext (com.linkedin.restli.server.PagingContext)1 PathKeys (com.linkedin.restli.server.PathKeys)1 ResourceContext (com.linkedin.restli.server.ResourceContext)1 ActionParam (com.linkedin.restli.server.annotations.ActionParam)1 AssocKeyParam (com.linkedin.restli.server.annotations.AssocKeyParam)1 Context (com.linkedin.restli.server.annotations.Context)1 HeaderParam (com.linkedin.restli.server.annotations.HeaderParam)1 PagingContextParam (com.linkedin.restli.server.annotations.PagingContextParam)1 ParSeqContext (com.linkedin.restli.server.annotations.ParSeqContext)1 PathKeysParam (com.linkedin.restli.server.annotations.PathKeysParam)1 QueryParam (com.linkedin.restli.server.annotations.QueryParam)1