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.http.annotation;
014
015import static org.apache.juneau.internal.ArrayUtils.*;
016
017import java.lang.annotation.*;
018
019import org.apache.juneau.annotation.*;
020
021/**
022 * Utility classes and methods for the {@link Tag @XXX} annotation.
023 *
024 * <h5 class='section'>See Also:</h5><ul>
025 * </ul>
026 */
027public class TagAnnotation {
028
029   //-----------------------------------------------------------------------------------------------------------------
030   // Static
031   //-----------------------------------------------------------------------------------------------------------------
032
033   /** Default value */
034   public static final Tag DEFAULT = create().build();
035
036   /**
037    * Instantiates a new builder for this class.
038    *
039    * @return A new builder object.
040    */
041   public static Builder create() {
042      return new Builder();
043   }
044
045   //-----------------------------------------------------------------------------------------------------------------
046   // Builder
047   //-----------------------------------------------------------------------------------------------------------------
048
049   /**
050    * Builder class.
051    *
052    * <h5 class='section'>See Also:</h5><ul>
053    *    <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
054    * </ul>
055    */
056   public static class Builder extends AnnotationBuilder {
057
058      ExternalDocs externalDocs = ExternalDocsAnnotation.DEFAULT;
059      String name="";
060      String[] description={};
061
062      /**
063       * Constructor.
064       */
065      protected Builder() {
066         super(Tag.class);
067      }
068
069      /**
070       * Instantiates a new {@link Tag @Tag} object initialized with this builder.
071       *
072       * @return A new {@link Tag @Tag} object.
073       */
074      public Tag build() {
075         return new Impl(this);
076      }
077
078      /**
079       * Sets the {@link Tag#description} property on this annotation.
080       *
081       * @param value The new value for this property.
082       * @return This object.
083       */
084      public Builder description(String...value) {
085         this.description = value;
086         return this;
087      }
088
089      /**
090       * Sets the {@link Tag#externalDocs} property on this annotation.
091       *
092       * @param value The new value for this property.
093       * @return This object.
094       */
095      public Builder externalDocs(ExternalDocs value) {
096         this.externalDocs = value;
097         return this;
098      }
099
100      /**
101       * Sets the {@link Tag#name} property on this annotation.
102       *
103       * @param value The new value for this property.
104       * @return This object.
105       */
106      public Builder name(String value) {
107         this.name = value;
108         return this;
109      }
110
111      // <FluentSetters>
112
113      // </FluentSetters>
114   }
115
116   //-----------------------------------------------------------------------------------------------------------------
117   // Implementation
118   //-----------------------------------------------------------------------------------------------------------------
119
120   private static class Impl extends AnnotationImpl implements Tag {
121
122      private final ExternalDocs externalDocs;
123      private final String name;
124      private final String[] description;
125
126      Impl(Builder b) {
127         super(b);
128         this.description = copyOf(b.description);
129         this.externalDocs = b.externalDocs;
130         this.name = b.name;
131         postConstruct();
132      }
133
134      @Override /* Tag */
135      public String[] description() {
136         return description;
137      }
138
139      @Override /* Tag */
140      public ExternalDocs externalDocs() {
141         return externalDocs;
142      }
143
144      @Override /* Tag */
145      public String name() {
146         return name;
147      }
148   }
149}