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.marshall.html; 018 019import static org.apache.juneau.commons.utils.Shorts.*; 020 021import java.lang.annotation.*; 022 023import org.apache.juneau.commons.*; 024 025/** 026 * Utility classes and methods for the {@link HtmlLink @HtmlLink} annotation. 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HtmlSupport">HTML</a> 030 * </ul> 031 */ 032public class HtmlLinkAnnotation { 033 034 /** 035 * Prevents instantiation. 036 */ 037 private HtmlLinkAnnotation() {} 038 039 /** 040 * Builder class. 041 * 042 * <h5 class='section'>See Also:</h5><ul> 043 * <li class='jm'>{@link org.apache.juneau.marshall.MarshallingContext.Builder#annotations(Annotation...)} 044 * </ul> 045 */ 046 public static class Builder extends AnnotationObject.Builder { 047 048 private String[] description = {}; 049 private String nameProperty = ""; 050 private String uriProperty = ""; 051 052 /** 053 * Constructor. 054 */ 055 protected Builder() { 056 super(HtmlLink.class); 057 } 058 059 /** 060 * Instantiates a new {@link HtmlLink @HtmlLink} object initialized with this builder. 061 * 062 * @return A new {@link HtmlLink @HtmlLink} object. 063 */ 064 public HtmlLink build() { 065 return new Object(this); 066 } 067 068 /** 069 * Sets the description property on this annotation. 070 * 071 * @param value The new value for this property. 072 * @return This object. 073 */ 074 public Builder description(String...value) { 075 description = value; 076 return this; 077 } 078 079 /** 080 * Sets the {@link HtmlLink#nameProperty()} property on this annotation. 081 * 082 * @param value The new value for this property. 083 * @return This object. 084 */ 085 public Builder nameProperty(String value) { 086 nameProperty = value; 087 return this; 088 } 089 090 /** 091 * Sets the {@link HtmlLink#uriProperty()} property on this annotation. 092 * 093 * @param value The new value for this property. 094 * @return This object. 095 */ 096 public Builder uriProperty(String value) { 097 uriProperty = value; 098 return this; 099 } 100 101 } 102 103 @SuppressWarnings({ 104 "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods 105 }) 106 private static class Object extends AnnotationObject implements HtmlLink { 107 108 private final String[] description; 109 private final String nameProperty; 110 private final String uriProperty; 111 112 Object(HtmlLinkAnnotation.Builder b) { 113 super(b); 114 description = cp(b.description); 115 nameProperty = b.nameProperty; 116 uriProperty = b.uriProperty; 117 } 118 119 @Override /* Overridden from HtmlLink */ 120 public String nameProperty() { 121 return nameProperty; 122 } 123 124 @Override /* Overridden from HtmlLink */ 125 public String uriProperty() { 126 return uriProperty; 127 } 128 129 @Override /* Overridden from annotation */ 130 public String[] description() { 131 return description; 132 } 133 } 134 135 /** Default value */ 136 public static final HtmlLink DEFAULT = create().build(); 137 138 /** 139 * Instantiates a new builder for this class. 140 * 141 * @return A new builder object. 142 */ 143 public static Builder create() { 144 return new Builder(); 145 } 146}