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.html;
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 Html @Html} 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 Html @Html} 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>@HtmlApply</ja>(on=<js>"com.example.Foo"</js>, value=<ja>@Html</ja>(format=HtmlFormat.XML))
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(HtmlApply.Array.class)
048@ContextApply(HtmlApplyAnnotation.Applier.class)
049public @interface HtmlApply {
050
051   /**
052    * The {@link Html @Html} annotation to apply.
053    *
054    * @return The annotation value.
055    */
056   Html value();
057
058   /**
059    * Dynamically apply this annotation to the specified classes/methods/fields.
060    *
061    * <p>
062    * Identifies the targets this annotation applies to using fully-qualified names.
063    *
064    * <h5 class='section'>See Also:</h5><ul>
065    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
066    * </ul>
067    *
068    * @return The annotation value.
069    */
070   String[] on() default {};
071
072   /**
073    * Dynamically apply this annotation to the specified classes.
074    *
075    * <p>
076    * Identical to {@link #on()} except allows you to specify class objects instead of strings.
077    *
078    * <h5 class='section'>See Also:</h5><ul>
079    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
080    * </ul>
081    *
082    * @return The annotation value.
083    */
084   Class<?>[] onClass() default {};
085
086   /**
087    * A collection of {@link HtmlApply @HtmlApply annotations}.
088    */
089   @Documented
090   @Target({ TYPE, METHOD })
091   @Retention(RUNTIME)
092   public @interface Array {
093
094      /**
095       * The child annotations.
096       *
097       * @return The annotation value.
098       */
099      HtmlApply[] value();
100   }
101}