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.rest.server;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021import java.lang.annotation.*;
022
023import org.apache.juneau.commons.*;
024import org.apache.juneau.marshall.encoders.*;
025import org.apache.juneau.rest.server.guard.*;
026import org.apache.juneau.rest.server.matcher.*;
027
028/**
029 * Utility classes and methods for the {@link RestDelete @RestDelete} annotation.
030 *
031 * <h5 class='section'>See Also:</h5><ul>
032 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestOpAnnotatedMethods">@RestOp-Annotated Method</a>
033 * </ul>
034 */
035public class RestDeleteAnnotation {
036
037   /**
038    * Private constructor to prevent instantiation.
039    */
040   private RestDeleteAnnotation() {
041      // Utility class - prevent instantiation
042   }
043
044   /**
045    * Builder class.
046    *
047    * <h5 class='section'>See Also:</h5><ul>
048    *    <li class='jm'>{@link org.apache.juneau.marshall.MarshallingContext.Builder#annotations(Annotation...)}
049    * </ul>
050    */
051   @SuppressWarnings({
052      "unchecked" // Type erasure requires cast for Builder inheritance
053   })
054   public static class Builder extends AnnotationObject.Builder {
055
056      private String[] description = {};
057      private Class<? extends RestGuard>[] guards = new Class[0];
058      private Class<? extends RestMatcher>[] matchers = new Class[0];
059      private Class<? extends Encoder>[] encoders = new Class[0];
060      private OpSwagger swagger = OpSwaggerAnnotation.DEFAULT;
061      private String clientVersion = "";
062      private String defaultAccept = "";
063      private String defaultCharset = "";
064      private String observability = "";
065      private String asyncCompletionExecutor = "";
066      private String metricName = "";
067      private String metricTags = "";
068      private String problemDetails = "";
069      private String debugMarshalling = "";
070      private String rolesDeclared = "";
071      private String roleGuard = "";
072      private String summary = "";
073      private String value = "";
074      private String[] defaultRequestQueryData = {};
075      private String[] defaultRequestAttributes = {};
076      private String[] defaultRequestHeaders = {};
077      private String[] defaultResponseHeaders = {};
078      private String[] allowedParserOptions = {};
079      private String[] allowedSerializerOptions = {};
080      private String[] noInherit = {};
081      private String[] path = {};
082
083      /**
084       * Constructor.
085       */
086      protected Builder() {
087         super(RestDelete.class);
088      }
089
090      /**
091       * Instantiates a new {@link RestDelete @RestDelete} object initialized with this builder.
092       *
093       * @return A new {@link RestDelete @RestDelete} object.
094       */
095      public RestDelete build() {
096         return new Object(this);
097      }
098
099      /**
100       * Sets the description property on this annotation.
101       *
102       * @param value The new value for this property.
103       * @return This object.
104       */
105      public Builder description(String...value) {
106         description = value;
107         return this;
108      }
109
110      /**
111       * Sets the {@link RestDelete#clientVersion()} property on this annotation.
112       *
113       * @param value The new value for this property.
114       * @return This object.
115       */
116      public Builder clientVersion(String value) {
117         clientVersion = value;
118         return this;
119      }
120
121      /**
122       * Sets the {@link RestDelete#defaultAccept()} property on this annotation.
123       *
124       * @param value The new value for this property.
125       * @return This object.
126       */
127      public Builder defaultAccept(String value) {
128         defaultAccept = value;
129         return this;
130      }
131
132      /**
133       * Sets the {@link RestDelete#defaultCharset()} property on this annotation.
134       *
135       * @param value The new value for this property.
136       * @return This object.
137       */
138      public Builder defaultCharset(String value) {
139         defaultCharset = value;
140         return this;
141      }
142
143      /**
144       * Sets the {@link RestDelete#defaultRequestAttributes()} property on this annotation.
145       *
146       * @param value The new value for this property.
147       * @return This object.
148       */
149      public Builder defaultRequestAttributes(String...value) {
150         defaultRequestAttributes = value;
151         return this;
152      }
153
154      /**
155       * Sets the {@link RestDelete#defaultRequestHeaders()} property on this annotation.
156       *
157       * @param value The new value for this property.
158       * @return This object.
159       */
160      public Builder defaultRequestHeaders(String...value) {
161         defaultRequestHeaders = value;
162         return this;
163      }
164
165      /**
166       * Sets the {@link RestDelete#defaultRequestQueryData()} property on this annotation.
167       *
168       * @param value The new value for this property.
169       * @return This object.
170       */
171      public Builder defaultRequestQueryData(String...value) {
172         defaultRequestQueryData = value;
173         return this;
174      }
175
176      /**
177       * Sets the {@link RestDelete#defaultResponseHeaders()} property on this annotation.
178       *
179       * @param value The new value for this property.
180       * @return This object.
181       */
182      public Builder defaultResponseHeaders(String...value) {
183         defaultResponseHeaders = value;
184         return this;
185      }
186
187      /**
188       * Sets the {@link RestDelete#encoders()} property on this annotation.
189       *
190       * @param value The new value for this property.
191       * @return This object.
192       */
193      @SafeVarargs
194      public final Builder encoders(Class<? extends Encoder>...value) {
195         encoders = value;
196         return this;
197      }
198
199      /**
200       * Sets the {@link RestDelete#guards()} property on this annotation.
201       *
202       * @param value The new value for this property.
203       * @return This object.
204       */
205      @SafeVarargs
206      public final Builder guards(Class<? extends RestGuard>...value) {
207         guards = value;
208         return this;
209      }
210
211      /**
212       * Sets the {@link RestDelete#matchers()} property on this annotation.
213       *
214       * @param value The new value for this property.
215       * @return This object.
216       */
217      @SafeVarargs
218      public final Builder matchers(Class<? extends RestMatcher>...value) {
219         matchers = value;
220         return this;
221      }
222
223      /**
224       * Sets the {@link RestDelete#path()} property on this annotation.
225       *
226       * @param value The new value for this property.
227       * @return This object.
228       */
229      public Builder path(String...value) {
230         path = value;
231         return this;
232      }
233
234      /**
235       * Sets the {@link RestDelete#problemDetails()} property on this annotation.
236       *
237       * @param value The new value for this property.
238       * @return This object.
239       */
240      public Builder problemDetails(String value) {
241         problemDetails = value;
242         return this;
243      }
244
245      /**
246       * Sets the {@link RestDelete#debugMarshalling()} property on this annotation.
247       *
248       * @param value The new value for this property.
249       * @return This object.
250       */
251      public Builder debugMarshalling(String value) {
252         debugMarshalling = value;
253         return this;
254      }
255
256      /**
257       * Sets the {@link RestDelete#observability()} property on this annotation.
258       *
259       * @param value The new value for this property.
260       * @return This object.
261       */
262      public Builder observability(String value) {
263         observability = value;
264         return this;
265      }
266
267      /**
268       * Sets the {@link RestDelete#asyncCompletionExecutor()} property on this annotation.
269       *
270       * @param value The new value for this property.
271       * @return This object.
272       */
273      public Builder asyncCompletionExecutor(String value) {
274         asyncCompletionExecutor = value;
275         return this;
276      }
277
278      /**
279       * Sets the {@link RestDelete#metricName()} property on this annotation.
280       *
281       * @param value The new value for this property.
282       * @return This object.
283       */
284      public Builder metricName(String value) {
285         metricName = value;
286         return this;
287      }
288
289      /**
290       * Sets the {@link RestDelete#metricTags()} property on this annotation.
291       *
292       * @param value The new value for this property.
293       * @return This object.
294       */
295      public Builder metricTags(String value) {
296         metricTags = value;
297         return this;
298      }
299
300      /**
301       * Sets the {@link RestDelete#allowedSerializerOptions()} property on this annotation.
302       *
303       * @param value The new value for this property.
304       * @return This object.
305       */
306      public Builder allowedSerializerOptions(String...value) {
307         allowedSerializerOptions = value;
308         return this;
309      }
310
311      /**
312       * Sets the {@link RestDelete#allowedParserOptions()} property on this annotation.
313       *
314       * @param value The new value for this property.
315       * @return This object.
316       */
317      public Builder allowedParserOptions(String...value) {
318         allowedParserOptions = value;
319         return this;
320      }
321
322      /**
323       * Sets the {@link RestDelete#noInherit()} property on this annotation.
324       *
325       * @param value The new value for this property.
326       * @return This object.
327       */
328      public Builder noInherit(String...value) {
329         noInherit = value;
330         return this;
331      }
332
333      /**
334       * Sets the {@link RestDelete#roleGuard()} property on this annotation.
335       *
336       * @param value The new value for this property.
337       * @return This object.
338       */
339      public Builder roleGuard(String value) {
340         roleGuard = value;
341         return this;
342      }
343
344      /**
345       * Sets the {@link RestDelete#rolesDeclared()} property on this annotation.
346       *
347       * @param value The new value for this property.
348       * @return This object.
349       */
350      public Builder rolesDeclared(String value) {
351         rolesDeclared = value;
352         return this;
353      }
354
355      /**
356       * Sets the {@link RestDelete#summary()} property on this annotation.
357       *
358       * @param value The new value for this property.
359       * @return This object.
360       */
361      public Builder summary(String value) {
362         summary = value;
363         return this;
364      }
365
366      /**
367       * Sets the {@link RestDelete#swagger()} property on this annotation.
368       *
369       * @param value The new value for this property.
370       * @return This object.
371       */
372      public Builder swagger(OpSwagger value) {
373         swagger = value;
374         return this;
375      }
376
377      /**
378       * Sets the {@link RestDelete#value()} property on this annotation.
379       *
380       * @param value The new value for this property.
381       * @return This object.
382       */
383      public Builder value(String value) {
384         this.value = value;
385         return this;
386      }
387
388   }
389
390   @SuppressWarnings({
391      "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
392   })
393   private static class Object extends AnnotationObject implements RestDelete {
394
395      private final String[] description;
396      private final Class<? extends RestGuard>[] guards;
397      private final Class<? extends RestMatcher>[] matchers;
398      private final Class<? extends Encoder>[] encoders;
399      private final OpSwagger swagger;
400      private final String clientVersion;
401      private final String defaultAccept;
402      private final String defaultCharset;
403      private final String observability;
404      private final String asyncCompletionExecutor;
405      private final String metricName;
406      private final String metricTags;
407      private final String problemDetails;
408      private final String debugMarshalling;
409      private final String rolesDeclared;
410      private final String roleGuard;
411      private final String summary;
412      private final String value;
413      private final String[] defaultRequestQueryData;
414      private final String[] defaultRequestAttributes;
415      private final String[] defaultRequestHeaders;
416      private final String[] defaultResponseHeaders;
417      private final String[] allowedParserOptions;
418      private final String[] allowedSerializerOptions;
419      private final String[] noInherit;
420      private final String[] path;
421
422      Object(RestDeleteAnnotation.Builder b) {
423         super(b);
424         description = cp(b.description);
425         clientVersion = b.clientVersion;
426         defaultAccept = b.defaultAccept;
427         defaultCharset = b.defaultCharset;
428         defaultRequestQueryData = cp(b.defaultRequestQueryData);
429         defaultRequestAttributes = cp(b.defaultRequestAttributes);
430         defaultRequestHeaders = cp(b.defaultRequestHeaders);
431         defaultResponseHeaders = cp(b.defaultResponseHeaders);
432         encoders = cp(b.encoders);
433         guards = cp(b.guards);
434         matchers = cp(b.matchers);
435         allowedParserOptions = cp(b.allowedParserOptions);
436         allowedSerializerOptions = cp(b.allowedSerializerOptions);
437         noInherit = cp(b.noInherit);
438         path = cp(b.path);
439         observability = b.observability;
440         asyncCompletionExecutor = b.asyncCompletionExecutor;
441         metricName = b.metricName;
442         metricTags = b.metricTags;
443         problemDetails = b.problemDetails;
444         debugMarshalling = b.debugMarshalling;
445         roleGuard = b.roleGuard;
446         rolesDeclared = b.rolesDeclared;
447         summary = b.summary;
448         swagger = b.swagger;
449         value = b.value;
450      }
451
452      @Override /* Overridden from RestDelete */
453      public String clientVersion() {
454         return clientVersion;
455      }
456
457      @Override /* Overridden from RestDelete */
458      public String defaultAccept() {
459         return defaultAccept;
460      }
461
462      @Override /* Overridden from RestDelete */
463      public String defaultCharset() {
464         return defaultCharset;
465      }
466
467      @Override /* Overridden from RestDelete */
468      public String[] defaultRequestAttributes() {
469         return defaultRequestAttributes;
470      }
471
472      @Override /* Overridden from RestDelete */
473      public String[] defaultRequestHeaders() {
474         return defaultRequestHeaders;
475      }
476
477      @Override /* Overridden from RestDelete */
478      public String[] defaultRequestQueryData() {
479         return defaultRequestQueryData;
480      }
481
482      @Override /* Overridden from RestDelete */
483      public String[] defaultResponseHeaders() {
484         return defaultResponseHeaders;
485      }
486
487      @Override /* Overridden from RestDelete */
488      public Class<? extends Encoder>[] encoders() {
489         return encoders;
490      }
491
492      @Override /* Overridden from RestDelete */
493      public Class<? extends RestGuard>[] guards() {
494         return guards;
495      }
496
497      @Override /* Overridden from RestDelete */
498      public Class<? extends RestMatcher>[] matchers() {
499         return matchers;
500      }
501
502      @Override /* Overridden from RestDelete */
503      public String[] allowedParserOptions() {
504         return allowedParserOptions;
505      }
506
507      @Override /* Overridden from RestDelete */
508      public String[] allowedSerializerOptions() {
509         return allowedSerializerOptions;
510      }
511
512      @Override /* Overridden from RestDelete */
513      public String[] noInherit() {
514         return noInherit;
515      }
516
517      @Override /* Overridden from RestDelete */
518      public String[] path() {
519         return path;
520      }
521
522      @Override /* Overridden from RestDelete */
523      public String observability() {
524         return observability;
525      }
526
527      @Override /* Overridden from RestDelete */
528      public String asyncCompletionExecutor() {
529         return asyncCompletionExecutor;
530      }
531
532      @Override /* Overridden from RestDelete */
533      public String metricName() {
534         return metricName;
535      }
536
537      @Override /* Overridden from RestDelete */
538      public String metricTags() {
539         return metricTags;
540      }
541
542      @Override /* Overridden from RestDelete */
543      public String problemDetails() {
544         return problemDetails;
545      }
546
547      @Override /* Overridden from RestDelete */
548      public String debugMarshalling() {
549         return debugMarshalling;
550      }
551
552      @Override /* Overridden from RestDelete */
553      public String roleGuard() {
554         return roleGuard;
555      }
556
557      @Override /* Overridden from RestDelete */
558      public String rolesDeclared() {
559         return rolesDeclared;
560      }
561
562      @Override /* Overridden from RestDelete */
563      public String summary() {
564         return summary;
565      }
566
567      @Override /* Overridden from RestDelete */
568      public OpSwagger swagger() {
569         return swagger;
570      }
571
572      @Override /* Overridden from RestDelete */
573      public String value() {
574         return value;
575      }
576
577      @Override /* Overridden from annotation */
578      public String[] description() {
579         return description;
580      }
581   }
582
583   /** Default value */
584   public static final RestDelete DEFAULT = create().build();
585
586   /**
587    * Instantiates a new builder for this class.
588    *
589    * @return A new builder object.
590    */
591   public static Builder create() {
592      return new Builder();
593   }
594}