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 setting the name of a POJO as it's known by its parent 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 * <h5 class='section'>Notes:</h5><ul> 031 * <li class='note'> 032 * The annotated field or method does not need to be public. 033 * </ul> 034 * 035 * <h5 class='section'>See Also:</h5><ul> 036 * <li class='link'><a class="doclink" href="../../../../index.html#jm.NamePropertyAnnotation">@NameProperty Annotation</a> 037 038 * </ul> 039 */ 040@Target({METHOD,FIELD,TYPE}) 041@Retention(RUNTIME) 042@Inherited 043@Repeatable(NamePropertyAnnotation.Array.class) 044@ContextApply(NamePropertyAnnotation.Applier.class) 045public @interface NameProperty { 046 047 /** 048 * Dynamically apply this annotation to the specified methods/fields. 049 * 050 * <p> 051 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing method/field. 052 * It is ignored when the annotation is applied directly to methods/fields. 053 * 054 * <h5 class='section'>Valid patterns:</h5> 055 * <ul class='spaced-list'> 056 * <li>Methods: 057 * <ul> 058 * <li>Fully qualified with args: 059 * <ul> 060 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 061 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 062 * <li><js>"com.foo.MyClass.myMethod()"</js> 063 * </ul> 064 * <li>Fully qualified: 065 * <ul> 066 * <li><js>"com.foo.MyClass.myMethod"</js> 067 * </ul> 068 * <li>Simple with args: 069 * <ul> 070 * <li><js>"MyClass.myMethod(String,int)"</js> 071 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 072 * <li><js>"MyClass.myMethod()"</js> 073 * </ul> 074 * <li>Simple: 075 * <ul> 076 * <li><js>"MyClass.myMethod"</js> 077 * </ul> 078 * <li>Simple inner class: 079 * <ul> 080 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 081 * <li><js>"Inner1$Inner2.myMethod"</js> 082 * <li><js>"Inner2.myMethod"</js> 083 * </ul> 084 * </ul> 085 * <li>Fields: 086 * <ul> 087 * <li>Fully qualified: 088 * <ul> 089 * <li><js>"com.foo.MyClass.myField"</js> 090 * </ul> 091 * <li>Simple: 092 * <ul> 093 * <li><js>"MyClass.myField"</js> 094 * </ul> 095 * <li>Simple inner class: 096 * <ul> 097 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 098 * <li><js>"Inner1$Inner2.myField"</js> 099 * <li><js>"Inner2.myField"</js> 100 * </ul> 101 * </ul> 102 * <li>A comma-delimited list of anything on this list. 103 * </ul> 104 * 105 * <h5 class='section'>See Also:</h5><ul> 106 * <li class='link'><a class="doclink" href="../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 107 * </ul> 108 * 109 * @return The annotation value. 110 */ 111 String[] on() default {}; 112}