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   // UonParser
048   //-------------------------------------------------------------------------------------------------------------------
049
050   /**
051    * Configuration property: Decode <js>"%xx"</js> sequences.
052    *
053    * <p>
054    * Specify <js>"true"</js> if URI encoded characters should be decoded, <js>"false"</js> if they've already been decoded
055    * before being passed to this parser.
056    *
057    * <ul class='notes'>
058    *    <li>
059    *       Possible values:
060    *       <ul>
061    *          <li><js>"true"</js>
062    *          <li><js>"false"</js>
063    *       </ul>
064    *    <li>
065    *       The default is <js>"false"</js> for {@link UonParser}, <js>"true"</js> for {@link UrlEncodingParser}.
066    *    <li>
067    *       Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
068    *    <li>
069    *       A default global value can be set via the system property <js>"UonParser.decoding.b"</js>.
070    * </ul>
071    *
072    * <ul class='seealso'>
073    *    <li class='jf'>{@link UonParser#UON_decoding}
074    * </ul>
075    */
076   String decoding() default "";
077
078   /**
079    * Configuration property:  Validate end.
080    *
081    * <p>
082    * If <js>"true"</js>, after parsing a POJO from the input, verifies that the remaining input in
083    * the stream consists of only comments or whitespace.
084    *
085    * <ul class='notes'>
086    *    <li>
087    *       Possible values:
088    *       <ul>
089    *          <li><js>"true"</js>
090    *          <li><js>"false"</js> (default)
091    *       </ul>
092    *    <li>
093    *       Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
094    *    <li>
095    *       A default global value can be set via the system property <js>"UonParser.validateEnd.b"</js>.
096    * </ul>
097
098    * <ul class='seealso'>
099    *    <li class='jf'>{@link UonParser#UON_validateEnd}
100    * </ul>
101    */
102   String validateEnd() default "";
103
104   //-------------------------------------------------------------------------------------------------------------------
105   // UonSerializer
106   //-------------------------------------------------------------------------------------------------------------------
107
108   /**
109    * Configuration property:  Add <js>"_type"</js> properties when needed.
110    *
111    * <p>
112    * If <js>"true"</js>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
113    * through reflection.
114    *
115    * <p>
116    * When present, this value overrides the {@link Serializer#SERIALIZER_addBeanTypes} setting and is
117    * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
118    *
119    * <ul class='notes'>
120    *    <li>
121    *       Possible values:
122    *       <ul>
123    *          <li><js>"true"</js>
124    *          <li><js>"false"</js> (default)
125    *       </ul>
126    *    <li>
127    *       Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
128    *    <li>
129    *       A default global value can be set via the system property <js>"UonSerializer.addBeanTypes.b"</js>.
130    * </ul>
131    *
132    * <ul class='seealso'>
133    *    <li class='jf'>{@link UonSerializer#UON_addBeanTypes}
134    * </ul>
135    */
136   String addBeanTypes() default "";
137
138   /**
139    * Configuration property:  Encode non-valid URI characters.
140    *
141    * <p>
142    * Encode non-valid URI characters with <js>"%xx"</js> constructs.
143    *
144    * <p>
145    * If <js>"true"</js>, non-valid URI characters will be converted to <js>"%xx"</js> sequences.
146    * <br>Set to <js>"false"</js> if parameter value is being passed to some other code that will already perform
147    * URL-encoding of non-valid URI characters.
148    *
149    * <p>
150    * Possible values:
151    * <ul>
152    *    <li><js>"true"</js>
153    *    <li><js>"false"</js>
154    * </ul>
155    *
156    * <ul class='notes'>
157    *    <li>
158    *       Possible values:
159    *       <ul>
160    *          <li><js>"true"</js>
161    *          <li><js>"false"</js>
162    *       </ul>
163    *    <li>
164    *       The default is <js>"false"</js> for {@link UonSerializer}, <js>"true"</js> for {@link UrlEncodingSerializer}.
165    *    <li>
166    *       Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
167    *    <li>
168    *       A default global value can be set via the system property <js>"UonSerializer.encoding.b"</js>.
169    * </ul>
170    *
171    * <ul class='seealso'>
172    *    <li class='jf'>{@link UonSerializer#UON_encoding}
173    * </ul>
174    */
175   String encoding() default "";
176
177   /**
178    * Configuration property:  Format to use for query/form-data/header values.
179    *
180    * <p>
181    * Specifies the format to use for URL GET parameter keys and values.
182    *
183    * <ul class='notes'>
184    *    <li>
185    *       Possible values:
186    *       <ul>
187    *          <li><js>"UON"</js> (default) - Use UON notation for parameters.
188    *          <li><js>"PLAINTEXT"</js> - Use plain text for parameters.
189    *       </ul>
190    *    <li>
191    *       Supports {@doc DefaultSvlVariables} (e.g. <js>"$C{myConfigVar}"</js>).
192    *    <li>
193    *       A default global value can be set via the system property <js>"UonSerializer.paramFormat.s"</js>.
194    * </ul>
195    *
196    * <ul class='seealso'>
197    *    <li class='jf'>{@link UonSerializer#UON_paramFormat}
198    * </ul>
199    */
200   String paramFormat() default "";
201}