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.marshall;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.commons.bean.*;
025
026/**
027 * Dynamically applies a {@link BeanProp @BeanProp} annotation to specified classes, methods, or fields.
028 *
029 * <p>
030 * This annotation separates the <b>targeting</b> concern ({@link #on()}/{@link #onClass()}) from the
031 * <b>content</b> concern ({@link #value()}), enabling {@link BeanProp @BeanProp} to be a pure data annotation
032 * without marshall-specific application machinery.
033 *
034 * <h5 class='section'>Example:</h5>
035 * <p class='bjava'>
036 *    <ja>@BeanPropApply</ja>(on=<js>"com.example.Foo.bar"</js>, value=<ja>@BeanProp</ja>(ro=<js>"true"</js>))
037 *    <jk>public class</jk> MyConfig {}
038 * </p>
039 *
040 * <h5 class='section'>See Also:</h5><ul>
041 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
042 * </ul>
043 */
044@Documented
045@Target({ TYPE, METHOD })
046@Retention(RUNTIME)
047@Repeatable(BeanPropApply.Array.class)
048@ContextApply(BeanPropApplyAnnotation.Applier.class)
049public @interface BeanPropApply {
050
051   /**
052    * The {@link BeanProp @BeanProp} annotation to apply.
053    *
054    * @return The annotation value.
055    */
056   BeanProp value();
057
058   /**
059    * Dynamically apply this annotation to the specified classes/methods/fields.
060    *
061    * <h5 class='section'>See Also:</h5><ul>
062    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
063    * </ul>
064    *
065    * @return The annotation value.
066    */
067   String[] on() default {};
068
069   /**
070    * Dynamically apply this annotation to the specified classes.
071    *
072    * <p>
073    * Identical to {@link #on()} except allows you to specify class objects instead of strings.
074    *
075    * <h5 class='section'>See Also:</h5><ul>
076    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
077    * </ul>
078    *
079    * @return The annotation value.
080    */
081   Class<?>[] onClass() default {};
082
083   /**
084    * A collection of {@link BeanPropApply @BeanPropApply annotations}.
085    */
086   @Documented
087   @Target({ TYPE, METHOD })
088   @Retention(RUNTIME)
089   public @interface Array {
090
091      /**
092       * The child annotations.
093       *
094       * @return The annotation value.
095       */
096      BeanPropApply[] value();
097   }
098}