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.toml;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.marshall.*;
025
026/**
027 * Dynamically applies a {@link Toml @Toml} 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 Toml @Toml} 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>@TomlApply</ja>(onClass=MyBean.<jk>class</jk>, value=<ja>@Toml</ja>)
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(TomlApply.Array.class)
048@ContextApply(TomlApplyAnnotation.Applier.class)
049public @interface TomlApply {
050
051   /**
052    * The {@link Toml @Toml} annotation to apply.
053    *
054    * @return The annotation value.
055    */
056   Toml 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    * <h5 class='section'>See Also:</h5><ul>
073    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
074    * </ul>
075    *
076    * @return The annotation value.
077    */
078   Class<?>[] onClass() default {};
079
080   /**
081    * A collection of {@link TomlApply @TomlApply annotations}.
082    */
083   @Documented
084   @Target({ TYPE, METHOD })
085   @Retention(RUNTIME)
086   public @interface Array {
087
088      /**
089       * The child annotations.
090       *
091       * @return The annotation value.
092       */
093      TomlApply[] value();
094   }
095}