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 * Used to identify a class or bean property as a URI. 026 * 027 * <p> 028 * Can be used in the following locations: 029 * <ul> 030 * <li>Classes that should be treated as URIs when serialized. 031 * <li>Methods/fields whose values should be treated as URIs when serialized. 032 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 033 * </ul> 034 * 035 * <p> 036 * This annotation allows you to identify other classes that return URIs via <c>toString()</c> as URI objects. 037 * 038 * <h5 class='section'>See Also:</h5><ul> 039 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/MarshallingUris">URIs</a> 040 041 * </ul> 042 */ 043@Documented 044@Target({TYPE,FIELD,METHOD}) 045@Retention(RUNTIME) 046@Inherited 047@Repeatable(UriAnnotation.Array.class) 048@ContextApply(UriAnnotation.Applier.class) 049public @interface Uri { 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 class/method/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 class/method/field. 064 * It is ignored when the annotation is applied directly to class/method/fields. 065 * 066 * <h5 class='section'>Valid patterns:</h5> 067 * <ul class='spaced-list'> 068 * <li>Classes: 069 * <ul> 070 * <li>Fully qualified: 071 * <ul> 072 * <li><js>"com.foo.MyClass"</js> 073 * </ul> 074 * <li>Fully qualified inner class: 075 * <ul> 076 * <li><js>"com.foo.MyClass$Inner1$Inner2"</js> 077 * </ul> 078 * <li>Simple: 079 * <ul> 080 * <li><js>"MyClass"</js> 081 * </ul> 082 * <li>Simple inner: 083 * <ul> 084 * <li><js>"MyClass$Inner1$Inner2"</js> 085 * <li><js>"Inner1$Inner2"</js> 086 * <li><js>"Inner2"</js> 087 * </ul> 088 * </ul> 089 * <li>Methods: 090 * <ul> 091 * <li>Fully qualified with args: 092 * <ul> 093 * <li><js>"com.foo.MyClass.myMethod(String,int)"</js> 094 * <li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js> 095 * <li><js>"com.foo.MyClass.myMethod()"</js> 096 * </ul> 097 * <li>Fully qualified: 098 * <ul> 099 * <li><js>"com.foo.MyClass.myMethod"</js> 100 * </ul> 101 * <li>Simple with args: 102 * <ul> 103 * <li><js>"MyClass.myMethod(String,int)"</js> 104 * <li><js>"MyClass.myMethod(java.lang.String,int)"</js> 105 * <li><js>"MyClass.myMethod()"</js> 106 * </ul> 107 * <li>Simple: 108 * <ul> 109 * <li><js>"MyClass.myMethod"</js> 110 * </ul> 111 * <li>Simple inner class: 112 * <ul> 113 * <li><js>"MyClass$Inner1$Inner2.myMethod"</js> 114 * <li><js>"Inner1$Inner2.myMethod"</js> 115 * <li><js>"Inner2.myMethod"</js> 116 * </ul> 117 * </ul> 118 * <li>Fields: 119 * <ul> 120 * <li>Fully qualified: 121 * <ul> 122 * <li><js>"com.foo.MyClass.myField"</js> 123 * </ul> 124 * <li>Simple: 125 * <ul> 126 * <li><js>"MyClass.myField"</js> 127 * </ul> 128 * <li>Simple inner class: 129 * <ul> 130 * <li><js>"MyClass$Inner1$Inner2.myField"</js> 131 * <li><js>"Inner1$Inner2.myField"</js> 132 * <li><js>"Inner2.myField"</js> 133 * </ul> 134 * </ul> 135 * <li>A comma-delimited list of anything on this list. 136 * </ul> 137 * 138 * <h5 class='section'>See Also:</h5><ul> 139 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 140 * </ul> 141 * 142 * @return The annotation value. 143 */ 144 String[] on() default {}; 145 146 /** 147 * Dynamically apply this annotation to the specified classes. 148 * 149 * <p> 150 * Identical to {@link #on()} except allows you to specify class objects instead of a strings. 151 * 152 * <h5 class='section'>See Also:</h5><ul> 153 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 154 * </ul> 155 * 156 * @return The annotation value. 157 */ 158 Class<?>[] onClass() default {}; 159}