001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.rest.arg; 014 015import jakarta.servlet.http.*; 016 017import org.apache.juneau.reflect.*; 018import org.apache.juneau.rest.annotation.*; 019import org.apache.juneau.utils.*; 020 021/** 022 * Resolves method parameters on {@link RestOp}-annotated Java methods of types found on the {@link HttpServletResponse} object. 023 * 024 * <ul class='javatree'> 025 * <li class='jc'>{@link HttpServletResponse} 026 * </ul> 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'><a class="doclink" href="../../../../../index.html#jrs.JavaMethodParameters">Java Method Parameters</a> 030 * </ul> 031 */ 032public class HttpServletResponseArgs extends SimpleRestOperationArg { 033 034 /** 035 * Static creator. 036 * 037 * @param paramInfo The Java method parameter being resolved. 038 * @return A new arg, or <jk>null</jk> if the parameter type is not one of the supported types. 039 */ 040 public static HttpServletResponseArgs create(ParamInfo paramInfo) { 041 if (paramInfo.isType(HttpServletResponse.class)) 042 return new HttpServletResponseArgs(x->x); 043 return null; 044 } 045 046 /** 047 * Constructor. 048 * 049 * @param <T> The function return type. 050 * @param function The function for finding the arg. 051 */ 052 protected <T> HttpServletResponseArgs(ThrowingFunction<HttpServletResponse,T> function) { 053 super(session -> function.apply(session.getRestSession().getResponse())); 054 } 055}