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 NameProperty @NameProperty} annotation to specified methods or fields.
026 *
027 * <p>
028 * This annotation separates the <b>targeting</b> concern ({@link #on()}) from the
029 * <b>content</b> concern ({@link #value()}), enabling {@link NameProperty @NameProperty} 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>@NamePropertyApply</ja>(on=<js>"com.example.Foo.myField"</js>, value=<ja>@NameProperty</ja>)
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(NamePropertyApply.Array.class)
046@ContextApply(NamePropertyApplyAnnotation.Applier.class)
047public @interface NamePropertyApply {
048
049   /**
050    * The {@link NameProperty @NameProperty} annotation to apply.
051    *
052    * @return The annotation value.
053    */
054   NameProperty value();
055
056   /**
057    * Dynamically apply this annotation to the specified 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    * A collection of {@link NamePropertyApply @NamePropertyApply annotations}.
072    */
073   @Documented
074   @Target({ TYPE, METHOD })
075   @Retention(RUNTIME)
076   public @interface Array {
077
078      /**
079       * The child annotations.
080       *
081       * @return The annotation value.
082       */
083      NamePropertyApply[] value();
084   }
085}