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