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