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