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.html.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.lang.annotation.*; 019 020import org.apache.juneau.annotation.*; 021import org.apache.juneau.html.*; 022 023/** 024 * Used in conjunction with the {@link HtmlSerializer} class to define hyperlinks. 025 * 026 * <p> 027 * Can be used in the following locations: 028 * <ul> 029 * <li>Classes. 030 * <li><ja>@Rest</ja>-annotated classes and <ja>@RestOp</ja>-annotated methods when an {@link #on()} value is specified. 031 * </ul> 032 * 033 * <p> 034 * Annotation that can be used to specify that a class has a URL associated with it. 035 * 036 * <p> 037 * When rendered using the {@link org.apache.juneau.html.HtmlSerializer HtmlSerializer} class, this class will get 038 * rendered as a hyperlink like so... 039 * <p class='code'> 040 * <xt><a</xt> <xa>href</xa>=<xs>'hrefProperty'</xs><xt>></xt>nameProperty<xt></a></xt> 041 * </p> 042 * 043 * <h5 class='section'>See Also:</h5><ul> 044 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.HtmlDetails">HTML Details</a> 045 046 * </ul> 047 */ 048@Documented 049@Target({TYPE,METHOD}) 050@Retention(RUNTIME) 051@Inherited 052@Repeatable(HtmlLinkAnnotation.Array.class) 053@ContextApply(HtmlLinkAnnotation.Apply.class) 054public @interface HtmlLink { 055 056 /** 057 * The bean property whose value becomes the name in the hyperlink. 058 * 059 * @return The annotation value. 060 */ 061 String nameProperty() default "name"; 062 063 /** 064 * Dynamically apply this annotation to the specified classes. 065 * 066 * <p> 067 * Used in conjunction with {@link org.apache.juneau.BeanContext.Builder#applyAnnotations(Class...)} to dynamically apply an annotation to an existing class. 068 * It is ignored when the annotation is applied directly to classes. 069 * 070 * <h5 class='section'>Valid patterns:</h5> 071 * <ul class='spaced-list'> 072 * <li>Classes: 073 * <ul> 074 * <li>Fully qualified: <js>"com.foo.MyClass"</js> 075 * <li>Fully qualified inner class: <js>"com.foo.MyClass$Inner1$Inner2"</js> 076 * <li>Simple: <js>"MyClass"</js> 077 * <li>Simple inner: <js>"MyClass$Inner1$Inner2"</js> or <js>"Inner1$Inner2"</js> or <js>"Inner2"</js> 078 * </ul> 079 * <li>A comma-delimited list of anything on this list. 080 * </ul> 081 * 082 * <h5 class='section'>See Also:</h5><ul> 083 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 084 * </ul> 085 * 086 * @return The annotation value. 087 */ 088 String[] on() default {}; 089 090 /** 091 * Dynamically apply this annotation to the specified classes. 092 * 093 * <p> 094 * Identical to {@link #on()} except allows you to specify class objects instead of a strings. 095 * 096 * <h5 class='section'>See Also:</h5><ul> 097 * <li class='link'><a class="doclink" href="../../../../../index.html#jm.DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a> 098 * </ul> 099 * 100 * @return The annotation value. 101 */ 102 Class<?>[] onClass() default {}; 103 104 /** 105 * The bean property whose value becomes the url in the hyperlink. 106 * 107 * @return The annotation value. 108 */ 109 String uriProperty() default "uri"; 110}