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.annotation;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024/**
025 * Ignore classes, fields, and methods from being interpreted as bean or bean components.
026 *
027 * <p>
028 * Can be used in the following locations:
029 * <ul>
030 *    <li>Classes - Forces bean-like classes to be treated as non-beans.
031 *    <li>Methods - Forces getters/setters to be ignored.
032 *    <li>Fields - Forces bean fields to be ignored.
033 *    <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified.
034 * </ul>
035 *
036 * <h5 class='section'>See Also:</h5><ul>
037 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/BeanIgnoreAnnotation">@BeanIgnore Annotation</a>
038
039 * </ul>
040 */
041@Documented
042@Target({FIELD,METHOD,TYPE,CONSTRUCTOR})
043@Retention(RUNTIME)
044@Inherited
045@Repeatable(BeanIgnoreAnnotation.Array.class)
046@ContextApply(BeanIgnoreAnnotation.Applier.class)
047public @interface BeanIgnore {
048
049    /**
050     * Optional description for the exposed API.
051     *
052     * @return The annotation value.
053     * @since 9.2.0
054     */
055    String[] description() default {};
056
057   /**
058    * Dynamically apply this annotation to the specified classes/methods/fields/constructors.
059    *
060    * <p>
061    * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing class/method/field/constructor.
062    * It is ignored when the annotation is applied directly to classes/methods/fields/constructors.
063    *
064    * <h5 class='section'>Valid patterns:</h5>
065    * <ul class='spaced-list'>
066    *  <li>Classes:
067    *       <ul>
068    *          <li>Fully qualified:
069    *             <ul>
070    *                <li><js>"com.foo.MyClass"</js>
071    *             </ul>
072    *          <li>Fully qualified inner class:
073    *             <ul>
074    *                <li><js>"com.foo.MyClass$Inner1$Inner2"</js>
075    *             </ul>
076    *          <li>Simple:
077    *             <ul>
078    *                <li><js>"MyClass"</js>
079    *             </ul>
080    *          <li>Simple inner:
081    *             <ul>
082    *                <li><js>"MyClass$Inner1$Inner2"</js>
083    *                <li><js>"Inner1$Inner2"</js>
084    *                <li><js>"Inner2"</js>
085    *             </ul>
086    *       </ul>
087    *    <li>Methods:
088    *       <ul>
089    *          <li>Fully qualified with args:
090    *             <ul>
091    *                <li><js>"com.foo.MyClass.myMethod(String,int)"</js>
092    *                <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js>
093    *                <li><js>"com.foo.MyClass.myMethod()"</js>
094    *             </ul>
095    *          <li>Fully qualified:
096    *             <ul>
097    *                <li><js>"com.foo.MyClass.myMethod"</js>
098    *             </ul>
099    *          <li>Simple with args:
100    *             <ul>
101    *                <li><js>"MyClass.myMethod(String,int)"</js>
102    *                <li><js>"MyClass.myMethod(java.lang.String,int)"</js>
103    *                <li><js>"MyClass.myMethod()"</js>
104    *             </ul>
105    *          <li>Simple:
106    *             <ul>
107    *                <li><js>"MyClass.myMethod"</js>
108    *             </ul>
109    *          <li>Simple inner class:
110    *             <ul>
111    *                <li><js>"MyClass$Inner1$Inner2.myMethod"</js>
112    *                <li><js>"Inner1$Inner2.myMethod"</js>
113    *                <li><js>"Inner2.myMethod"</js>
114    *             </ul>
115    *       </ul>
116    *    <li>Fields:
117    *       <ul>
118    *          <li>Fully qualified:
119    *             <ul>
120    *                <li><js>"com.foo.MyClass.myField"</js>
121    *             </ul>
122    *          <li>Simple:
123    *             <ul>
124    *                <li><js>"MyClass.myField"</js>
125    *             </ul>
126    *          <li>Simple inner class:
127    *             <ul>
128    *                <li><js>"MyClass$Inner1$Inner2.myField"</js>
129    *                <li><js>"Inner1$Inner2.myField"</js>
130    *                <li><js>"Inner2.myField"</js>
131    *             </ul>
132    *       </ul>
133    *    <li>Constructors:
134    *       <ul>
135    *          <li>Fully qualified with args:
136    *             <ul>
137    *                <li><js>"com.foo.MyClass(String,int)"</js>
138    *                <li><js>"com.foo.MyClass(java.lang.String,int)"</js>
139    *                <li><js>"com.foo.MyClass()"</js>
140    *             </ul>
141    *          <li>Simple with args:
142    *             <ul>
143    *                <li><js>"MyClass(String,int)"</js>
144    *                <li><js>"MyClass(java.lang.String,int)"</js>
145    *                <li><js>"MyClass()"</js>
146    *             </ul>
147    *          <li>Simple inner class:
148    *             <ul>
149    *                <li><js>"MyClass$Inner1$Inner2()"</js>
150    *                <li><js>"Inner1$Inner2()"</js>
151    *                <li><js>"Inner2()"</js>
152    *             </ul>
153    *       </ul>
154    *    <li>A comma-delimited list of anything on this list.
155    * </ul>
156    *
157    * <h5 class='section'>See Also:</h5><ul>
158    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
159    * </ul>
160    *
161    * @return The annotation value.
162    */
163   String[] on() default {};
164
165   /**
166    * Dynamically apply this annotation to the specified classes.
167    *
168    * <p>
169    * Identical to {@link #on()} except allows you to specify class objects instead of a strings.
170    *
171    * <h5 class='section'>See Also:</h5><ul>
172    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
173    * </ul>
174    *
175    * @return The annotation value.
176    */
177   Class<?>[] onClass() default {};
178}
179