001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.uon.annotation;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.annotation.*;
025import org.apache.juneau.serializer.*;
026import org.apache.juneau.uon.*;
027import org.apache.juneau.urlencoding.*;
028
029/**
030 * Annotation for specifying config properties defined in {@link UonSerializer} and {@link UonParser}.
031 *
032 * <p>
033 * Used primarily for specifying bean configuration properties on REST classes and methods.
034 *
035 * <h5 class='section'>See Also:</h5><ul>
036 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/UonBasics">UON Basics</a>
037 * </ul>
038 */
039@Target({ TYPE, METHOD })
040@Retention(RUNTIME)
041@Inherited
042@ContextApply({ UonConfigAnnotation.SerializerApply.class, UonConfigAnnotation.ParserApply.class })
043public @interface UonConfig {
044
045   /**
046    * Add <js>"_type"</js> properties when needed.
047    *
048    * <p>
049    * If <js>"true"</js>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred
050    * through reflection.
051    *
052    * <p>
053    * When present, this value overrides the {@link org.apache.juneau.serializer.Serializer.Builder#addBeanTypes()} setting and is
054    * provided to customize the behavior of specific serializers in a {@link SerializerSet}.
055    *
056    * <ul class='values'>
057    *    <li><js>"true"</js>
058    *    <li><js>"false"</js> (default)
059    * </ul>
060    *
061    * <h5 class='section'>Notes:</h5><ul>
062    *    <li class='note'>
063    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
064    * </ul>
065    *
066    * <h5 class='section'>See Also:</h5><ul>
067    *    <li class='jm'>{@link org.apache.juneau.uon.UonSerializer.Builder#addBeanTypesUon()}
068    * </ul>
069    *
070    * @return The annotation value.
071    */
072   String addBeanTypes() default "";
073
074   /**
075    * Decode <js>"%xx"</js> sequences.
076    *
077    * <p>
078    * Specify <js>"true"</js> if URI encoded characters should be decoded, <js>"false"</js> if they've already been decoded
079    * before being passed to this parser.
080    *
081    * <ul class='values'>
082    *    <li><js>"true"</js> (default for {@link UrlEncodingParser})
083    *    <li><js>"false"</js> (default for {@link UonParser})
084    * </ul>
085    *
086    * <h5 class='section'>Notes:</h5><ul>
087    *    <li class='note'>
088    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
089    * </ul>
090    *
091    * <h5 class='section'>See Also:</h5><ul>
092    *    <li class='jm'>{@link org.apache.juneau.uon.UonParser.Builder#decoding()}
093    * </ul>
094    *
095    * @return The annotation value.
096    */
097   String decoding() default "";
098
099   /**
100    * Encode non-valid URI characters.
101    *
102    * <p>
103    * Encode non-valid URI characters with <js>"%xx"</js> constructs.
104    *
105    * <p>
106    * If <js>"true"</js>, non-valid URI characters will be converted to <js>"%xx"</js> sequences.
107    * <br>Set to <js>"false"</js> if parameter value is being passed to some other code that will already perform
108    * URL-encoding of non-valid URI characters.
109    *
110    * <ul class='values'>
111    *    <li><js>"true"</js> (default for {@link UrlEncodingSerializer})
112    *    <li><js>"false"</js> (default for {@link UonSerializer})
113    * </ul>
114    *
115    * <h5 class='section'>Notes:</h5><ul>
116    *    <li class='note'>
117    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
118    * </ul>
119    *
120    * <h5 class='section'>See Also:</h5><ul>
121    *    <li class='jm'>{@link org.apache.juneau.uon.UonSerializer.Builder#encoding()}
122    * </ul>
123    *
124    * @return The annotation value.
125    */
126   String encoding() default "";
127
128   /**
129    * Format to use for query/form-data/header values.
130    *
131    * <p>
132    * Specifies the format to use for URL GET parameter keys and values.
133    *
134    * <ul class='values'>
135    *    <li><js>"UON"</js> (default) - Use UON notation for parameters.
136    *    <li><js>"PLAINTEXT"</js> - Use plain text for parameters.
137    * </ul>
138    *
139    * <h5 class='section'>Notes:</h5><ul>
140    *    <li class='note'>
141    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
142    * </ul>
143    *
144    * <h5 class='section'>See Also:</h5><ul>
145    *    <li class='jm'>{@link org.apache.juneau.uon.UonSerializer.Builder#paramFormat(ParamFormat)}
146    * </ul>
147    *
148    * @return The annotation value.
149    */
150   String paramFormat() default "";
151
152   /**
153    * Optional rank for this config.
154    *
155    * <p>
156    * Can be used to override default ordering and application of config annotations.
157    *
158    * @return The annotation value.
159    */
160   int rank() default 0;
161
162   /**
163    * Validate end.
164    *
165    * <p>
166    * If <js>"true"</js>, after parsing a POJO from the input, verifies that the remaining input in
167    * the stream consists of only comments or whitespace.
168    *
169    * <ul class='values'>
170    *    <li><js>"true"</js>
171    *    <li><js>"false"</js> (default)
172    * </ul>
173    *
174    * <h5 class='section'>Notes:</h5><ul>
175    *    <li class='note'>
176    *       Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> (e.g. <js>"$C{myConfigVar}"</js>).
177    * </ul>
178   
179    * <h5 class='section'>See Also:</h5><ul>
180    *    <li class='jm'>{@link org.apache.juneau.uon.UonParser.Builder#validateEnd()}
181    * </ul>
182    *
183    * @return The annotation value.
184    */
185   String validateEnd() default "";
186}