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