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 java.lang.annotation.*;
016
017import org.apache.juneau.*;
018
019/**
020 * A concrete implementation of the {@link HtmlLink} annotation.
021 *
022 * <ul class='seealso'>
023 *    <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)}
024 * </ul>
025 */
026public class HtmlLinkAnnotation implements HtmlLink {
027
028   private String
029      on = "",
030      nameProperty = "",
031      uriProperty = "";
032
033   /**
034    * Constructor.
035    *
036    * @param on The initial value for the <c>on</c> property.
037    *    <br>See {@link HtmlLink#on()}
038    */
039   public HtmlLinkAnnotation(String on) {
040      on(on);
041   }
042
043   /**
044    * Constructor.
045    *
046    * @param on The initial value for the <c>on</c> property.
047    *    <br>See {@link HtmlLink#on()}
048    */
049   public HtmlLinkAnnotation(Class<?> on) {
050      on(on);
051   }
052
053   @Override
054   public Class<? extends Annotation> annotationType() {
055      return HtmlLink.class;
056   }
057
058   @Override
059   public String on() {
060      return on;
061   }
062
063   /**
064    * Sets the <c>on</c> property on this annotation.
065    *
066    * @param value The new value for this property.
067    * @return This object (for method chaining).
068    */
069   public HtmlLinkAnnotation on(String value) {
070      this.on = value;
071      return this;
072   }
073
074   /**
075    * Sets the <c>on</c> property on this annotation.
076    *
077    * @param value The new value for this property.
078    * @return This object (for method chaining).
079    */
080   public HtmlLinkAnnotation on(Class<?> value) {
081      this.on = value.getName();
082      return this;
083   }
084
085   @Override
086   public String nameProperty() {
087      return nameProperty;
088   }
089
090   /**
091    * Sets the <c>nameProperty</c> property on this annotation.
092    *
093    * @param value The new value for this property.
094    * @return This object (for method chaining).
095    */
096   public HtmlLinkAnnotation nameProperty(String value) {
097      this.nameProperty = value;
098      return this;
099   }
100
101   @Override
102   public String uriProperty() {
103      return uriProperty;
104   }
105
106   /**
107    * Sets the <c>uriProperty</c> property on this annotation.
108    *
109    * @param value The new value for this property.
110    * @return This object (for method chaining).
111    */
112   public HtmlLinkAnnotation uriProperty(String value) {
113      this.uriProperty = value;
114      return this;
115   }
116}