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.urlencoding.annotation;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.lang.annotation.*;
019
020import org.apache.juneau.urlencoding.*;
021
022/**
023 * Annotation that can be applied to classes, fields, and methods to tweak how they are handled by
024 * {@link UrlEncodingSerializer} and {@link UrlEncodingParser}.
025 */
026@Documented
027@Target({TYPE,FIELD,METHOD})
028@Retention(RUNTIME)
029@Inherited
030public @interface UrlEncoding {
031
032   /**
033    * When true, bean properties of type array or Collection will be expanded into multiple key/value pairings.
034    *
035    * <p>
036    * This annotation is identical in behavior to using the {@link UrlEncodingSerializer#URLENC_expandedParams}
037    * and {@link UrlEncodingParser#URLENC_expandedParams} properties, but applies to only instances of this bean.
038    */
039   boolean expandedParams() default false;
040
041   /**
042    * Dynamically apply this annotation to the specified classes/methods/fields.
043    *
044    * <p>
045    * Used in conjunction with the {@link UrlEncodingConfig#applyUrlEncoding()}.
046    * It is ignored when the annotation is applied directly to classes/methods/fields.
047    *
048    * <h5 class='section'>Valid patterns:</h5>
049    * <ul class='spaced-list'>
050    *  <li>Classes:
051    *       <ul>
052    *          <li>Fully qualified:
053    *             <ul>
054    *                <li><js>"com.foo.MyClass"</js>
055    *             </ul>
056    *          <li>Fully qualified inner class:
057    *             <ul>
058    *                <li><js>"com.foo.MyClass$Inner1$Inner2"</js>
059    *             </ul>
060    *          <li>Simple:
061    *             <ul>
062    *                <li><js>"MyClass"</js>
063    *             </ul>
064    *          <li>Simple inner:
065    *             <ul>
066    *                <li><js>"MyClass$Inner1$Inner2"</js>
067    *                <li><js>"Inner1$Inner2"</js>
068    *                <li><js>"Inner2"</js>
069    *             </ul>
070    *       </ul>
071    *    <li>Methods:
072    *       <ul>
073    *          <li>Fully qualified with args:
074    *             <ul>
075    *                <li><js>"com.foo.MyClass.myMethod(String,int)"</js>
076    *                <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js>
077    *                <li><js>"com.foo.MyClass.myMethod()"</js>
078    *             </ul>
079    *          <li>Fully qualified:
080    *             <ul>
081    *                <li><js>"com.foo.MyClass.myMethod"</js>
082    *             </ul>
083    *          <li>Simple with args:
084    *             <ul>
085    *                <li><js>"MyClass.myMethod(String,int)"</js>
086    *                <li><js>"MyClass.myMethod(java.lang.String,int)"</js>
087    *                <li><js>"MyClass.myMethod()"</js>
088    *             </ul>
089    *          <li>Simple:
090    *             <ul>
091    *                <li><js>"MyClass.myMethod"</js>
092    *             </ul>
093    *          <li>Simple inner class:
094    *             <ul>
095    *                <li><js>"MyClass$Inner1$Inner2.myMethod"</js>
096    *                <li><js>"Inner1$Inner2.myMethod"</js>
097    *                <li><js>"Inner2.myMethod"</js>
098    *             </ul>
099    *       </ul>
100    *    <li>Fields:
101    *       <ul>
102    *          <li>Fully qualified:
103    *             <ul>
104    *                <li><js>"com.foo.MyClass.myField"</js>
105    *             </ul>
106    *          <li>Simple:
107    *             <ul>
108    *                <li><js>"MyClass.myField"</js>
109    *             </ul>
110    *          <li>Simple inner class:
111    *             <ul>
112    *                <li><js>"MyClass$Inner1$Inner2.myField"</js>
113    *                <li><js>"Inner1$Inner2.myField"</js>
114    *                <li><js>"Inner2.myField"</js>
115    *             </ul>
116    *       </ul>
117    *    <li>A comma-delimited list of anything on this list.
118    * </ul>
119    *
120    * <ul class='seealso'>
121    *    <li class='link'>{@doc DynamicallyAppliedAnnotations}
122    * </ul>
123    */
124   String on() default "";
125}