![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.juneau.rest.arg.RestRequestArgs Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.rest.arg;
import java.io.*;
import java.util.*;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import org.apache.juneau.*;
import org.apache.juneau.cp.*;
import org.apache.juneau.dto.swagger.Swagger;
import org.apache.juneau.httppart.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.httppart.*;
import org.apache.juneau.svl.*;
import org.apache.juneau.utils.*;
/**
* Resolves method parameters on {@link RestOp}-annotated Java methods of types found on the {@link RestRequest} object.
*
*
* - {@link HttpServletRequest}
*
- {@link HttpPartParserSession}
*
- {@link HttpPartSerializerSession}
*
- {@link InputStream}
*
- {@link Locale}
*
- {@link Messages}
*
- {@link Reader}
*
- {@link RequestAttributes}
*
- {@link RequestContent}
*
- {@link RequestFormParams}
*
- {@link RequestHeaders}
*
- {@link RequestPathParams}
*
- {@link RequestQueryParams}
*
- {@link ResourceBundle}
*
- {@link RestRequest}
*
- {@link ServletInputStream}
*
- {@link Swagger}
*
- {@link TimeZone}
*
- {@link UriContext}
*
- {@link UriResolver}
*
- {@link VarResolverSession}
*
*
* See Also:
*/
public class RestRequestArgs extends SimpleRestOperationArg {
/**
* Static creator.
*
* @param paramInfo The Java method parameter being resolved.
* @return A new arg, or null if the parameter type is not one of the supported types.
*/
public static RestRequestArgs create(ParamInfo paramInfo) {
if (paramInfo.isType(HttpPartParserSession.class))
return new RestRequestArgs(RestRequest::getPartParserSession);
if (paramInfo.isType(HttpPartSerializerSession.class))
return new RestRequestArgs(RestRequest::getPartSerializerSession);
if (paramInfo.isType(InputStream.class))
return new RestRequestArgs(RestRequest::getInputStream);
if (paramInfo.isType(Locale.class))
return new RestRequestArgs(RestRequest::getLocale);
if (paramInfo.isType(Messages.class))
return new RestRequestArgs(RestRequest::getMessages);
if (paramInfo.isType(Reader.class))
return new RestRequestArgs(RestRequest::getReader);
if (paramInfo.isType(RequestAttributes.class))
return new RestRequestArgs(RestRequest::getAttributes);
if (paramInfo.isType(RequestContent.class))
return new RestRequestArgs(RestRequest::getContent);
if (paramInfo.isType(RequestFormParams.class))
return new RestRequestArgs(RestRequest::getFormParams);
if (paramInfo.isType(RequestHeaders.class))
return new RestRequestArgs(RestRequest::getHeaders);
if (paramInfo.isType(RequestPathParams.class))
return new RestRequestArgs(RestRequest::getPathParams);
if (paramInfo.isType(RequestQueryParams.class))
return new RestRequestArgs(RestRequest::getQueryParams);
if (paramInfo.isType(ResourceBundle.class))
return new RestRequestArgs(RestRequest::getMessages);
if (paramInfo.isType(RestRequest.class))
return new RestRequestArgs(x->x);
if (paramInfo.isType(ServletInputStream.class))
return new RestRequestArgs(RestRequest::getInputStream);
if (paramInfo.isType(Swagger.class))
return new RestRequestArgs(x->x.getSwagger().orElse(null));
if (paramInfo.isType(TimeZone.class))
return new RestRequestArgs(x->x.getTimeZone().orElse(null));
if (paramInfo.isType(UriContext.class))
return new RestRequestArgs(RestRequest::getUriContext);
if (paramInfo.isType(UriResolver.class))
return new RestRequestArgs(RestRequest::getUriResolver);
if (paramInfo.isType(VarResolverSession.class))
return new RestRequestArgs(RestRequest::getVarResolverSession);
return null;
}
/**
* Constructor.
*
* @param The function return type.
* @param function The function for finding the arg.
*/
protected RestRequestArgs(ThrowingFunction function) {
super(session -> function.apply(session.getRequest()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy