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.uon.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.serializer.*;
022import org.apache.juneau.uon.*;
023import org.apache.juneau.urlencoding.*;
024
025/**
026 * Annotation for specifying config properties defined in {@link UonSerializer} and {@link UonParser}.
027 *
028 * <p>
029 * Used primarily for specifying bean configuration properties on REST classes and methods.
030 */
031@Documented
032@Target({TYPE,METHOD})
033@Retention(RUNTIME)
034@Inherited
035@PropertyStoreApply(UonConfigApply.class)
036public @interface UonConfig {
037
038   /**
039    * Optional rank for this config.
040    *
041    * <p>
042    * Can be used to override default ordering and application of config annotations.
043    */
044   int rank() default 0;
045
046   //-------------------------------------------------------------------------------------------------------------------
047   // UonCommon
048   //-------------------------------------------------------------------------------------------------------------------
049
050   /**
051    * Dynamically applies {@link Uon @Uon} annotations to specified classes/methods/fields.
052    *
053    * <p>
054    * Provides an alternate approach for applying annotations using {@link Uon#on() @Uon.on} to specify the names
055    * to apply the annotation to.
056    *
057    * <ul class='seealso'>
058    *    <li class='link'>{@doc DynamicallyAppliedAnnotations}
059    * </ul>
060    */
061   Uon[] applyUon() default {};
062
063   //-------------------------------------------------------------------------------------------------------------------
064   // UonParser
065   //-------------------------------------------------------------------------------------------------------------------
066
067   /**
068    * Configuration property: Decode <js>"%xx"</js> sequences.
069    *
070    * <p>
071    * Specify <js>"true"</js> if URI encoded characters should be decoded, <js>"false"</js> if they've already been decoded
072    * before being passed to this parser.
073    *
074    * <ul class='notes'>
075    *    <li>
076    *       Possible values:
077    *       <ul>
078    *          <li><js>"true"</js>
079    *          <li><js>"false"</js>
080    *       </ul>
081    *    <li>
082    *       The default is <js>"false"</js> for {@link UonParser}, <js>"true"</js> for {@link UrlEncodingParser}.
083    *    <li>
084    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
085    * </ul>
086    *
087    * <ul class='seealso'>
088    *    <li class='jf'>{@link UonParser#UON_decoding}
089    * </ul>
090    */
091   String decoding() default "";
092
093   /**
094    * Configuration property:  Validate end.
095    *
096    * <p>
097    * If <js>"true"</js>, after parsing a POJO from the input, verifies that the remaining input in
098    * the stream consists of only comments or whitespace.
099    *
100    * <ul class='notes'>
101    *    <li>
102    *       Possible values:
103    *       <ul>
104    *          <li><js>"true"</js>
105    *          <li><js>"false"</js> (default)
106    *       </ul>
107    *    <li>
108    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
109    * </ul>
110
111    * <ul class='seealso'>
112    *    <li class='jf'>{@link UonParser#UON_validateEnd}
113    * </ul>
114    */
115   String validateEnd() default "";
116
117   //-------------------------------------------------------------------------------------------------------------------
118   // UonSerializer
119   //-------------------------------------------------------------------------------------------------------------------
120
121   /**
122    * Configuration property:  Add <js>"_type"</js> properties when needed.
123    *
124    * <p>
125    * If <js>"true"</js>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
126    * through reflection.
127    *
128    * <p>
129    * When present, this value overrides the {@link Serializer#SERIALIZER_addBeanTypes} setting and is
130    * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
131    *
132    * <ul class='notes'>
133    *    <li>
134    *       Possible values:
135    *       <ul>
136    *          <li><js>"true"</js>
137    *          <li><js>"false"</js> (default)
138    *       </ul>
139    *    <li>
140    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
141    * </ul>
142    *
143    * <ul class='seealso'>
144    *    <li class='jf'>{@link UonSerializer#UON_addBeanTypes}
145    * </ul>
146    */
147   String addBeanTypes() default "";
148
149   /**
150    * Configuration property:  Encode non-valid URI characters.
151    *
152    * <p>
153    * Encode non-valid URI characters with <js>"%xx"</js> constructs.
154    *
155    * <p>
156    * If <js>"true"</js>, non-valid URI characters will be converted to <js>"%xx"</js> sequences.
157    * <br>Set to <js>"false"</js> if parameter value is being passed to some other code that will already perform
158    * URL-encoding of non-valid URI characters.
159    *
160    * <p>
161    * Possible values:
162    * <ul>
163    *    <li><js>"true"</js>
164    *    <li><js>"false"</js>
165    * </ul>
166    *
167    * <ul class='notes'>
168    *    <li>
169    *       Possible values:
170    *       <ul>
171    *          <li><js>"true"</js>
172    *          <li><js>"false"</js>
173    *       </ul>
174    *    <li>
175    *       The default is <js>"false"</js> for {@link UonSerializer}, <js>"true"</js> for {@link UrlEncodingSerializer}.
176    *    <li>
177    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
178    * </ul>
179    *
180    * <ul class='seealso'>
181    *    <li class='jf'>{@link UonSerializer#UON_encoding}
182    * </ul>
183    */
184   String encoding() default "";
185
186   /**
187    * Configuration property:  Format to use for query/form-data/header values.
188    *
189    * <p>
190    * Specifies the format to use for URL GET parameter keys and values.
191    *
192    * <ul class='notes'>
193    *    <li>
194    *       Possible values:
195    *       <ul>
196    *          <li><js>"UON"</js> (default) - Use UON notation for parameters.
197    *          <li><js>"PLAINTEXT"</js> - Use plain text for parameters.
198    *       </ul>
199    *    <li>
200    *       Supports {@doc DefaultVarResolver} (e.g. <js>"$C{myConfigVar}"</js>).
201    * </ul>
202    *
203    * <ul class='seealso'>
204    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
205    * </ul>
206    */
207   String paramFormat() default "";
208}