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