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