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