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