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.annotation;
014
015import java.lang.annotation.*;
016
017import org.apache.juneau.*;
018import org.apache.juneau.transform.*;
019
020/**
021 * A concrete implementation of the {@link Bean} annotation.
022 *
023 * <ul class='seealso'>
024 *    <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)}
025 * </ul>
026 */
027public class BeanAnnotation implements Bean {
028
029   private String on = "";
030
031   private Class<?>[]
032      beanDictionary = new Class[0],
033      dictionary = new Class[0];
034   private Class<?>
035      interfaceClass = Object.class,
036      stopClass = Object.class;
037   private Class<? extends BeanInterceptor<?>>
038      interceptor = BeanInterceptor.Default.class;
039   private Class<? extends PropertyNamer>
040      propertyNamer = PropertyNamerDefault.class;
041   private String
042      bpi = "",
043      bpx = "",
044      bpro = "",
045      bpwo = "",
046      excludeProperties = "",
047      properties = "",
048      typeName = "",
049      typePropertyName = "";
050   boolean
051      fluentSetters = false,
052      sort = false;
053
054   /**
055    * Constructor.
056    *
057    * @param on The initial value for the <c>on</c> property.
058    */
059   public BeanAnnotation(String on) {
060      on(on);
061   }
062
063   /**
064    * Constructor.
065    *
066    * @param on The initial value for the <c>on</c> property.
067    */
068   public BeanAnnotation(Class<?> on) {
069      on(on);
070   }
071
072   @Override
073   public Class<? extends Annotation> annotationType() {
074      return Bean.class;
075   }
076
077   @Override
078   public Class<?>[] beanDictionary() {
079      return beanDictionary;
080   }
081
082   /**
083    * Sets the <c>beanDictionary</c> property on this annotation.
084    *
085    * @param value The new value for this property.
086    * @return This object (for method chaining).
087    */
088   public BeanAnnotation beanDictionary(Class<?>...value) {
089      this.beanDictionary = value;
090      return this;
091   }
092
093   @Override
094   public String bpi() {
095      return bpi;
096   }
097
098   /**
099    * Sets the <c>bpi</c> property on this annotation.
100    *
101    * @param value The new value for this property.
102    * @return This object (for method chaining).
103    */
104   public BeanAnnotation bpi(String value) {
105      this.bpi = value;
106      return this;
107   }
108
109   @Override
110   public String bpro() {
111      return bpro;
112   }
113
114   /**
115    * Sets the <c>bpro</c> property on this annotation.
116    *
117    * @param value The new value for this property.
118    * @return This object (for method chaining).
119    */
120   public BeanAnnotation bpro(String value) {
121      this.bpro = value;
122      return this;
123   }
124
125   @Override
126   public String bpwo() {
127      return bpwo;
128   }
129
130   /**
131    * Sets the <c>bpwo</c> property on this annotation.
132    *
133    * @param value The new value for this property.
134    * @return This object (for method chaining).
135    */
136   public BeanAnnotation bpwo(String value) {
137      this.bpwo = value;
138      return this;
139   }
140
141   @Override
142   public String bpx() {
143      return bpx;
144   }
145
146   /**
147    * Sets the <c>bpx</c> property on this annotation.
148    *
149    * @param value The new value for this property.
150    * @return This object (for method chaining).
151    */
152   public BeanAnnotation bpx(String value) {
153      this.bpx = value;
154      return this;
155   }
156
157   @Override
158   public Class<?>[] dictionary() {
159      return dictionary;
160   }
161
162   /**
163    * Sets the <c>dictionary</c> property on this annotation.
164    *
165    * @param value The new value for this property.
166    * @return This object (for method chaining).
167    */
168   public BeanAnnotation dictionary(Class<?>...value) {
169      this.dictionary = value;
170      return this;
171   }
172
173   @Override
174   public String excludeProperties() {
175      return excludeProperties;
176   }
177
178   /**
179    * Sets the <c>excludeProperties</c> property on this annotation.
180    *
181    * @param value The new value for this property.
182    * @return This object (for method chaining).
183    */
184   public BeanAnnotation excludeProperties(String value) {
185      this.excludeProperties = value;
186      return this;
187   }
188
189   @Override
190   public boolean fluentSetters() {
191      return fluentSetters;
192   }
193
194   /**
195    * Sets the <c>fluentSetters</c> property on this annotation.
196    *
197    * @param value The new value for this property.
198    * @return This object (for method chaining).
199    */
200   public BeanAnnotation fluentSetters(boolean value) {
201      this.fluentSetters = value;
202      return this;
203   }
204
205   @Override
206   public Class<?> interfaceClass() {
207      return interfaceClass;
208   }
209
210   /**
211    * Sets the <c>interfaceClass</c> property on this annotation.
212    *
213    * @param value The new value for this property.
214    * @return This object (for method chaining).
215    */
216   public BeanAnnotation interfaceClass(Class<?> value) {
217      this.interfaceClass = value;
218      return this;
219   }
220
221   @Override
222   public String on() {
223      return on;
224   }
225
226   /**
227    * Sets the <c>on</c> property on this annotation.
228    *
229    * @param value The new value for this property.
230    * @return This object (for method chaining).
231    */
232   public BeanAnnotation on(String value) {
233      this.on = value;
234      return this;
235   }
236
237   /**
238    * Sets the <c>on</c> property on this annotation.
239    *
240    * @param value The new value for this property.
241    * @return This object (for method chaining).
242    */
243   public BeanAnnotation on(Class<?> value) {
244      this.on = value.getName();
245      return this;
246   }
247
248   @Override
249   public String properties() {
250      return properties;
251   }
252
253   /**
254    * Sets the <c>properties</c> property on this annotation.
255    *
256    * @param value The new value for this property.
257    * @return This object (for method chaining).
258    */
259   public BeanAnnotation properties(String value) {
260      this.properties = value;
261      return this;
262   }
263
264   @Override
265   public Class<? extends BeanInterceptor<?>> interceptor() {
266      return interceptor;
267   }
268
269   /**
270    * Sets the <c>propertyFilter</c> property on this annotation.
271    *
272    * @param value The new value for this property.
273    * @return This object (for method chaining).
274    */
275   public BeanAnnotation interceptor(Class<? extends BeanInterceptor<?>> value) {
276      this.interceptor = value;
277      return this;
278   }
279
280   @Override
281   public Class<? extends PropertyNamer> propertyNamer() {
282      return propertyNamer;
283   }
284
285   /**
286    * Sets the <c>propertyNamer</c> property on this annotation.
287    *
288    * @param value The new value for this property.
289    * @return This object (for method chaining).
290    */
291   public BeanAnnotation propertyNamer(Class<? extends PropertyNamer> value) {
292      this.propertyNamer = value;
293      return this;
294   }
295
296   @Override
297   public boolean sort() {
298      return sort;
299   }
300
301   /**
302    * Sets the <c>sort</c> property on this annotation.
303    *
304    * @param value The new value for this property.
305    * @return This object (for method chaining).
306    */
307   public BeanAnnotation sort(boolean value) {
308      this.sort = value;
309      return this;
310   }
311
312   @Override
313   public Class<?> stopClass() {
314      return stopClass;
315   }
316
317   /**
318    * Sets the <c>stopClass</c> property on this annotation.
319    *
320    * @param value The new value for this property.
321    * @return This object (for method chaining).
322    */
323   public BeanAnnotation stopClass(Class<?> value) {
324      this.stopClass = value;
325      return this;
326   }
327
328   @Override
329   public String typeName() {
330      return typeName;
331   }
332
333   /**
334    * Sets the <c>typeName</c> property on this annotation.
335    *
336    * @param value The new value for this property.
337    * @return This object (for method chaining).
338    */
339   public BeanAnnotation typeName(String value) {
340      this.typeName = value;
341      return this;
342   }
343
344   @Override
345   public String typePropertyName() {
346      return typePropertyName;
347   }
348
349   /**
350    * Sets the <c>typePropertyName</c> property on this annotation.
351    *
352    * @param value The new value for this property.
353    * @return This object (for method chaining).
354    */
355   public BeanAnnotation typePropertyName(String value) {
356      this.typePropertyName = value;
357      return this;
358   }
359}