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.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.lang.annotation.*; 019 020import org.apache.juneau.rest.*; 021 022/** 023 * Identical to {@link HasFormData @HasFormData}, but only checks the existing of the parameter in the URL string, not 024 * URL-encoded form posts. 025 * 026 * <p> 027 * Unlike {@link HasFormData @HasFormData}, using this annotation does not result in the servlet reading the contents 028 * of URL-encoded form posts. 029 * Therefore, this annotation can be used in conjunction with the {@link Body @Body} annotation or 030 * {@link RestRequest#getBody()} method for <code>application/x-www-form-urlencoded POST</code> calls. 031 * 032 * <h5 class='section'>Example:</h5> 033 * <p class='bcode'> 034 * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>) 035 * <jk>public void</jk> doPost(<ja>@HasQuery</ja>(<js>"p1"</js>) <jk>boolean</jk> p1, <ja>@Body</ja> Bean myBean) { 036 * ... 037 * } 038 * </p> 039 * 040 * <p> 041 * This is functionally equivalent to the following code... 042 * <p class='bcode'> 043 * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>) 044 * <jk>public void</jk> doGet(RestRequest req) { 045 * <jk>boolean</jk> p1 = req.hasQueryParameter(<js>"p1"</js>); 046 * ... 047 * } 048 * </p> 049 * 050 * <h5 class='section'>See Also:</h5> 051 * <ul> 052 * <li class='link'><a class="doclink" href="../../../../../overview-summary.html#juneau-rest-server.Query">Overview > juneau-rest-server > @Query</a> 053 * </ul> 054 */ 055@Documented 056@Target(PARAMETER) 057@Retention(RUNTIME) 058@Inherited 059public @interface HasQuery { 060 061 /** 062 * URL query parameter name. 063 */ 064 String name() default ""; 065 066 /** 067 * A synonym for {@link #name()}. 068 * 069 * <p> 070 * Allows you to use shortened notation if you're only specifying the name. 071 */ 072 String value() default ""; 073}