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.annotation; 018 019import static java.lang.annotation.ElementType.*; 020import static java.lang.annotation.RetentionPolicy.*; 021 022import java.lang.annotation.*; 023 024/** 025 * Identifies a setter as a method for setting the name of a POJO as it's known by its parent object. 026 * 027 * <p> 028 * Can be used in the following locations: 029 * <ul> 030 * <li>Bean getter/setter/field. 031 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 032 * </ul> 033 * 034 * <h5 class='section'>Notes:</h5><ul> 035 * <li class='note'> 036 * The annotated field or method does not need to be public. 037 * </ul> 038 * 039 * <h5 class='section'>See Also:</h5><ul> 040 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/NamePropertyAnnotation">@NameProperty Annotation</a> 041 042 * </ul> 043 */ 044@Target({METHOD,FIELD,TYPE}) 045@Retention(RUNTIME) 046@Inherited 047@Repeatable(NamePropertyAnnotation.Array.class) 048@ContextApply(NamePropertyAnnotation.Applier.class) 049public @interface NameProperty { 050 051 /** 052 * Optional description for the exposed API. 053 * 054 * @return The annotation value. 055 * @since 9.2.0 056 */ 057 String[] description() default {}; 058 059 /** 060 * Dynamically apply this annotation to the specified methods/fields. 061 * 062 * <p> 063 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing method/field. 064 * It is ignored when the annotation is applied directly to methods/fields. 065 * 066 * <h5 class='section'>Valid patterns:</h5> 067 * <ul class='spaced-list'> 068 * <li>Methods: 069 * <ul> 070 * <li>Fully qualified with args: 071 * <ul> 072 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 073 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 074 * <li><js>"com.foo.MyClass.myMethod()"</js> 075 * </ul> 076 * <li>Fully qualified: 077 * <ul> 078 * <li><js>"com.foo.MyClass.myMethod"</js> 079 * </ul> 080 * <li>Simple with args: 081 * <ul> 082 * <li><js>"MyClass.myMethod(String,int)"</js> 083 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 084 * <li><js>"MyClass.myMethod()"</js> 085 * </ul> 086 * <li>Simple: 087 * <ul> 088 * <li><js>"MyClass.myMethod"</js> 089 * </ul> 090 * <li>Simple inner class: 091 * <ul> 092 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 093 * <li><js>"Inner1$Inner2.myMethod"</js> 094 * <li><js>"Inner2.myMethod"</js> 095 * </ul> 096 * </ul> 097 * <li>Fields: 098 * <ul> 099 * <li>Fully qualified: 100 * <ul> 101 * <li><js>"com.foo.MyClass.myField"</js> 102 * </ul> 103 * <li>Simple: 104 * <ul> 105 * <li><js>"MyClass.myField"</js> 106 * </ul> 107 * <li>Simple inner class: 108 * <ul> 109 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 110 * <li><js>"Inner1$Inner2.myField"</js> 111 * <li><js>"Inner2.myField"</js> 112 * </ul> 113 * </ul> 114 * <li>A comma-delimited list of anything on this list. 115 * </ul> 116 * 117 * <h5 class='section'>See Also:</h5><ul> 118 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 119 * </ul> 120 * 121 * @return The annotation value. 122 */ 123 String[] on() default {}; 124}