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