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.annotation.*; 021import org.apache.juneau.urlencoding.*; 022 023/** 024 * Annotation that can be applied to classes, fields, and methods to tweak how they are handled by 025 * {@link UrlEncodingSerializer} and {@link UrlEncodingParser}. 026 * 027 * <p> 028 * Can be used in the following locations: 029 * <ul> 030 * <li>Marshalled classes/methods/fields. 031 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 032 * </ul> 033 * 034 * <h5 class='section'>See Also:</h5><ul> 035 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.UrlEncodingDetails">URL-Encoding Details</a> 036 037 * </ul> 038 */ 039@Documented 040@Target({TYPE,FIELD,METHOD}) 041@Retention(RUNTIME) 042@Inherited 043@Repeatable(UrlEncodingAnnotation.Array.class) 044@ContextApply(UrlEncodingAnnotation.Apply.class) 045public @interface UrlEncoding { 046 047 /** 048 * When true, bean properties of type array or Collection will be expanded into multiple key/value pairings. 049 * 050 * <p> 051 * This annotation is identical in behavior to using the {@link org.apache.juneau.urlencoding.UrlEncodingSerializer.Builder#expandedParams()} 052 * and {@link org.apache.juneau.urlencoding.UrlEncodingParser.Builder#expandedParams()} properties, but applies to only instances of this bean. 053 * 054 * @return The annotation value. 055 */ 056 boolean expandedParams() default false; 057 058 /** 059 * Dynamically apply this annotation to the specified classes/methods/fields. 060 * 061 * <p> 062 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing class/method/field. 063 * It is ignored when the annotation is applied directly to classes/methods/fields. 064 * 065 * <h5 class='section'>Valid patterns:</h5> 066 * <ul class='spaced-list'> 067 * <li>Classes: 068 * <ul> 069 * <li>Fully qualified: 070 * <ul> 071 * <li><js>"com.foo.MyClass"</js> 072 * </ul> 073 * <li>Fully qualified inner class: 074 * <ul> 075 * <li><js>"com.foo.MyClass$Inner1$Inner2"</js> 076 * </ul> 077 * <li>Simple: 078 * <ul> 079 * <li><js>"MyClass"</js> 080 * </ul> 081 * <li>Simple inner: 082 * <ul> 083 * <li><js>"MyClass$Inner1$Inner2"</js> 084 * <li><js>"Inner1$Inner2"</js> 085 * <li><js>"Inner2"</js> 086 * </ul> 087 * </ul> 088 * <li>Methods: 089 * <ul> 090 * <li>Fully qualified with args: 091 * <ul> 092 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 093 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 094 * <li><js>"com.foo.MyClass.myMethod()"</js> 095 * </ul> 096 * <li>Fully qualified: 097 * <ul> 098 * <li><js>"com.foo.MyClass.myMethod"</js> 099 * </ul> 100 * <li>Simple with args: 101 * <ul> 102 * <li><js>"MyClass.myMethod(String,int)"</js> 103 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 104 * <li><js>"MyClass.myMethod()"</js> 105 * </ul> 106 * <li>Simple: 107 * <ul> 108 * <li><js>"MyClass.myMethod"</js> 109 * </ul> 110 * <li>Simple inner class: 111 * <ul> 112 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 113 * <li><js>"Inner1$Inner2.myMethod"</js> 114 * <li><js>"Inner2.myMethod"</js> 115 * </ul> 116 * </ul> 117 * <li>Fields: 118 * <ul> 119 * <li>Fully qualified: 120 * <ul> 121 * <li><js>"com.foo.MyClass.myField"</js> 122 * </ul> 123 * <li>Simple: 124 * <ul> 125 * <li><js>"MyClass.myField"</js> 126 * </ul> 127 * <li>Simple inner class: 128 * <ul> 129 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 130 * <li><js>"Inner1$Inner2.myField"</js> 131 * <li><js>"Inner2.myField"</js> 132 * </ul> 133 * </ul> 134 * <li>A comma-delimited list of anything on this list. 135 * </ul> 136 * 137 * <h5 class='section'>See Also:</h5><ul> 138 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 139 * </ul> 140 * 141 * @return The annotation value. 142 */ 143 String[] on() default {}; 144 145 /** 146 * Dynamically apply this annotation to the specified classes. 147 * 148 * <p> 149 * Identical to {@link #on()} except allows you to specify class objects instead of a strings. 150 * 151 * <h5 class='section'>See Also:</h5><ul> 152 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 153 * </ul> 154 * 155 * @return The annotation value. 156 */ 157 Class<?>[] onClass() default {}; 158}