001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.lang.annotation.*; 019 020/** 021 * Identifies a setter as a method for adding a parent reference to a child object. 022 * 023 * <p> 024 * Can be used in the following locations: 025 * <ul> 026 * <li>Bean getter/setter/field. 027 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 028 * </ul> 029 * 030 * <p> 031 * Used by the parsers to add references to parent objects in child objects. 032 * 033 * <h5 class='section'>Notes:</h5><ul> 034 * <li class='note'> 035 * The annotated field or method does not need to be public. 036 * </ul> 037 * 038 * <h5 class='section'>See Also:</h5><ul> 039 * <li class='link'><a class="doclink" href="../../../../index.html#jm.ParentPropertyAnnotation">@ParentProperty Annotation</a> 040 041 * </ul> 042 */ 043@Target({METHOD,FIELD,TYPE}) 044@Retention(RUNTIME) 045@Inherited 046@Repeatable(ParentPropertyAnnotation.Array.class) 047@ContextApply(ParentPropertyAnnotation.Applier.class) 048public @interface ParentProperty { 049 050 /** 051 * Dynamically apply this annotation to the specified methods/fields. 052 * 053 * <p> 054 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing method/field. 055 * It is ignored when the annotation is applied directly to methods/fields. 056 * 057 * <h5 class='section'>Valid patterns:</h5> 058 * <ul class='spaced-list'> 059 * <li>Methods: 060 * <ul> 061 * <li>Fully qualified with args: 062 * <ul> 063 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 064 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 065 * <li><js>"com.foo.MyClass.myMethod()"</js> 066 * </ul> 067 * <li>Fully qualified: 068 * <ul> 069 * <li><js>"com.foo.MyClass.myMethod"</js> 070 * </ul> 071 * <li>Simple with args: 072 * <ul> 073 * <li><js>"MyClass.myMethod(String,int)"</js> 074 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 075 * <li><js>"MyClass.myMethod()"</js> 076 * </ul> 077 * <li>Simple: 078 * <ul> 079 * <li><js>"MyClass.myMethod"</js> 080 * </ul> 081 * <li>Simple inner class: 082 * <ul> 083 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 084 * <li><js>"Inner1$Inner2.myMethod"</js> 085 * <li><js>"Inner2.myMethod"</js> 086 * </ul> 087 * </ul> 088 * <li>Fields: 089 * <ul> 090 * <li>Fully qualified: 091 * <ul> 092 * <li><js>"com.foo.MyClass.myField"</js> 093 * </ul> 094 * <li>Simple: 095 * <ul> 096 * <li><js>"MyClass.myField"</js> 097 * </ul> 098 * <li>Simple inner class: 099 * <ul> 100 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 101 * <li><js>"Inner1$Inner2.myField"</js> 102 * <li><js>"Inner2.myField"</js> 103 * </ul> 104 * </ul> 105 * <li>A comma-delimited list of anything on this list. 106 * </ul> 107 * 108 * <h5 class='section'>See Also:</h5><ul> 109 * <li class='link'><a class="doclink" href="../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 110 * </ul> 111 * 112 * @return The annotation value. 113 */ 114 String[] on() default {}; 115}