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.jsonschema.annotation;
014
015import java.lang.annotation.*;
016
017import org.apache.juneau.*;
018
019/**
020 * A concrete implementation of the {@link Schema} annotation.
021 *
022 * <p>
023 * Annotations can be applied programmatically using {@link BeanContextBuilder#annotations(Annotation...)}.
024 */
025public class SchemaAnnotation implements Schema {
026
027   private String on = "";
028
029   private String
030      $ref = "",
031      format = "",
032      f = "",
033      title = "",
034      multipleOf = "",
035      mo = "",
036      maximum = "",
037      max = "",
038      minimum = "",
039      min = "",
040      pattern = "",
041      p = "",
042      type = "",
043      t = "",
044      collectionFormat = "",
045      cf = "",
046      discriminator = "";
047
048   private String[]
049      description = new String[0],
050      d = new String[0],
051      _default = new String[0],
052      df = new String[0],
053      _enum = new String[0],
054      e = new String[0],
055      allOf = new String[0],
056      properties = new String[0],
057      additionalProperties = new String[0],
058      xml = new String[0],
059      example = new String[0],
060      ex = new String[0],
061      examples = new String[0],
062      exs = new String[0],
063      value = new String[0];
064
065   private boolean
066      exclusiveMaximum = false,
067      emax = false,
068      exclusiveMinimum = false,
069      emin = false,
070      uniqueItems = false,
071      ui = false,
072      required = false,
073      r = false,
074      readOnly = false,
075      ro = false,
076      ignore = false;
077
078   private long
079      maxLength = -1,
080      maxl = -1,
081      minLength = -1,
082      minl = -1,
083      maxItems = -1,
084      maxi = -1,
085      minItems = -1,
086      mini = -1,
087      maxProperties = -1,
088      maxp = -1,
089      minProperties = -1,
090      minp = -1;
091
092   private Items items = new ItemsAnnotation();
093   private ExternalDocs externalDocs = new ExternalDocsAnnotation();
094
095
096   /**
097    * Constructor.
098    *
099    * @param on The initial value for the <c>on</c> property.
100    *    <br>See {@link Schema#on()}
101    */
102   public SchemaAnnotation(String on) {
103      this.on = on;
104   }
105
106   /**
107    * Constructor.
108    */
109   public SchemaAnnotation() {}
110
111   @Override
112   public Class<? extends Annotation> annotationType() {
113      return Schema.class;
114   }
115
116   @Override /* Schema */
117   public String[] _default() {
118      return _default;
119   }
120
121   /**
122    * Sets the <c>_default</c> property on this annotation.
123    *
124    * @param value The new value for this property.
125    * @return This object (for method chaining).
126    */
127   public SchemaAnnotation _default(String...value) {
128      this._default = value;
129      return this;
130   }
131
132   @Override /* Schema */
133   public String[] df() {
134      return df;
135   }
136
137   /**
138    * Sets the <c>df</c> property on this annotation.
139    *
140    * @param value The new value for this property.
141    * @return This object (for method chaining).
142    */
143   public SchemaAnnotation df(String...value) {
144      this.df = value;
145      return this;
146   }
147
148   @Override /* Schema */
149   public String[] _enum() {
150      return _enum;
151   }
152
153   /**
154    * Sets the <c>_enum</c> property on this annotation.
155    *
156    * @param value The new value for this property.
157    * @return This object (for method chaining).
158    */
159   public SchemaAnnotation _enum(String...value) {
160      this._enum = value;
161      return this;
162   }
163
164   @Override /* Schema */
165   public String[] e() {
166      return e;
167   }
168
169   /**
170    * Sets the <c>e</c> property on this annotation.
171    *
172    * @param value The new value for this property.
173    * @return This object (for method chaining).
174    */
175   public SchemaAnnotation e(String...value) {
176      this.e = value;
177      return this;
178   }
179
180   @Override /* Schema */
181   public String $ref() {
182      return $ref;
183   }
184
185   /**
186    * Sets the <c>$ref</c> property on this annotation.
187    *
188    * @param value The new value for this property.
189    * @return This object (for method chaining).
190    */
191   public SchemaAnnotation $ref(String value) {
192      this.$ref = value;
193      return this;
194   }
195
196   @Override /* Schema */
197   public String[] additionalProperties() {
198      return additionalProperties;
199   }
200
201   /**
202    * Sets the <c>additionalProperties</c> property on this annotation.
203    *
204    * @param value The new value for this property.
205    * @return This object (for method chaining).
206    */
207   public SchemaAnnotation additionalProperties(String...value) {
208      this.additionalProperties = value;
209      return this;
210   }
211
212   @Override /* Schema */
213   public String[] allOf() {
214      return allOf;
215   }
216
217   /**
218    * Sets the <c>allOf</c> property on this annotation.
219    *
220    * @param value The new value for this property.
221    * @return This object (for method chaining).
222    */
223   public SchemaAnnotation allOf(String...value) {
224      this.allOf = value;
225      return this;
226   }
227
228   @Override /* Schema */
229   public String collectionFormat() {
230      return collectionFormat;
231   }
232
233   /**
234    * Sets the <c>collectionFormat</c> property on this annotation.
235    *
236    * @param value The new value for this property.
237    * @return This object (for method chaining).
238    */
239   public SchemaAnnotation collectionFormat(String value) {
240      this.collectionFormat = value;
241      return this;
242   }
243
244   @Override /* Schema */
245   public String cf() {
246      return cf;
247   }
248
249   /**
250    * Sets the <c>cf</c> property on this annotation.
251    *
252    * @param value The new value for this property.
253    * @return This object (for method chaining).
254    */
255   public SchemaAnnotation cf(String value) {
256      this.cf = value;
257      return this;
258   }
259
260   @Override /* Schema */
261   public String[] description() {
262      return description;
263   }
264
265   /**
266    * Sets the <c>description</c> property on this annotation.
267    *
268    * @param value The new value for this property.
269    * @return This object (for method chaining).
270    */
271   public SchemaAnnotation description(String...value) {
272      this.description = value;
273      return this;
274   }
275
276   @Override /* Schema */
277   public String[] d() {
278      return d;
279   }
280
281   /**
282    * Sets the <c>d</c> property on this annotation.
283    *
284    * @param value The new value for this property.
285    * @return This object (for method chaining).
286    */
287   public SchemaAnnotation d(String...value) {
288      this.d = value;
289      return this;
290   }
291
292   @Override /* Schema */
293   public String discriminator() {
294      return discriminator;
295   }
296
297   /**
298    * Sets the <c>discriminator</c> property on this annotation.
299    *
300    * @param value The new value for this property.
301    * @return This object (for method chaining).
302    */
303   public SchemaAnnotation discriminator(String value) {
304      this.discriminator = value;
305      return this;
306   }
307
308   @Override /* Schema */
309   public String[] example() {
310      return example;
311   }
312
313   /**
314    * Sets the <c>example</c> property on this annotation.
315    *
316    * @param value The new value for this property.
317    * @return This object (for method chaining).
318    */
319   public SchemaAnnotation example(String...value) {
320      this.example = value;
321      return this;
322   }
323
324   @Override /* Schema */
325   public String[] ex() {
326      return ex;
327   }
328
329   /**
330    * Sets the <c>ex</c> property on this annotation.
331    *
332    * @param value The new value for this property.
333    * @return This object (for method chaining).
334    */
335   public SchemaAnnotation ex(String...value) {
336      this.ex = value;
337      return this;
338   }
339
340   @Override /* Schema */
341   public String[] examples() {
342      return examples;
343   }
344
345   /**
346    * Sets the <c>examples</c> property on this annotation.
347    *
348    * @param value The new value for this property.
349    * @return This object (for method chaining).
350    */
351   public SchemaAnnotation examples(String...value) {
352      this.examples = value;
353      return this;
354   }
355
356   @Override /* Schema */
357   public String[] exs() {
358      return exs;
359   }
360
361   /**
362    * Sets the <c>exs</c> property on this annotation.
363    *
364    * @param value The new value for this property.
365    * @return This object (for method chaining).
366    */
367   public SchemaAnnotation exs(String...value) {
368      this.exs = value;
369      return this;
370   }
371
372   @Override /* Schema */
373   public boolean exclusiveMaximum() {
374      return exclusiveMaximum;
375   }
376
377   /**
378    * Sets the <c>exclusiveMaximum</c> property on this annotation.
379    *
380    * @param value The new value for this property.
381    * @return This object (for method chaining).
382    */
383   public SchemaAnnotation exclusiveMaximum(boolean value) {
384      this.exclusiveMaximum = value;
385      return this;
386   }
387
388   @Override /* Schema */
389   public boolean emax() {
390      return emax;
391   }
392
393   /**
394    * Sets the <c>emax</c> property on this annotation.
395    *
396    * @param value The new value for this property.
397    * @return This object (for method chaining).
398    */
399   public SchemaAnnotation emax(boolean value) {
400      this.emax = value;
401      return this;
402   }
403
404   @Override /* Schema */
405   public boolean exclusiveMinimum() {
406      return exclusiveMinimum;
407   }
408
409   /**
410    * Sets the <c>exclusiveMinimum</c> property on this annotation.
411    *
412    * @param value The new value for this property.
413    * @return This object (for method chaining).
414    */
415   public SchemaAnnotation exclusiveMinimum(boolean value) {
416      this.exclusiveMinimum = value;
417      return this;
418   }
419
420   @Override /* Schema */
421   public boolean emin() {
422      return emin;
423   }
424
425   /**
426    * Sets the <c>emin</c> property on this annotation.
427    *
428    * @param value The new value for this property.
429    * @return This object (for method chaining).
430    */
431   public SchemaAnnotation emin(boolean value) {
432      this.emin = value;
433      return this;
434   }
435
436   @Override /* Schema */
437   public ExternalDocs externalDocs() {
438      return externalDocs;
439   }
440
441   /**
442    * Sets the <c>externalDocs</c> property on this annotation.
443    *
444    * @param value The new value for this property.
445    * @return This object (for method chaining).
446    */
447   public SchemaAnnotation externalDocs(ExternalDocs value) {
448      this.externalDocs = value;
449      return this;
450   }
451
452   @Override /* Schema */
453   public String format() {
454      return format;
455   }
456
457   /**
458    * Sets the <c>format</c> property on this annotation.
459    *
460    * @param value The new value for this property.
461    * @return This object (for method chaining).
462    */
463   public SchemaAnnotation format(String value) {
464      this.format = value;
465      return this;
466   }
467
468   @Override /* Schema */
469   public String f() {
470      return f;
471   }
472
473   /**
474    * Sets the <c>f</c> property on this annotation.
475    *
476    * @param value The new value for this property.
477    * @return This object (for method chaining).
478    */
479   public SchemaAnnotation f(String value) {
480      this.f = value;
481      return this;
482   }
483
484   @Override /* Schema */
485   public boolean ignore() {
486      return ignore;
487   }
488
489   /**
490    * Sets the <c>ignore</c> property on this annotation.
491    *
492    * @param value The new value for this property.
493    * @return This object (for method chaining).
494    */
495   public SchemaAnnotation ignore(boolean value) {
496      this.ignore = value;
497      return this;
498   }
499
500   @Override /* Schema */
501   public Items items() {
502      return items;
503   }
504
505   /**
506    * Sets the <c>items</c> property on this annotation.
507    *
508    * @param value The new value for this property.
509    * @return This object (for method chaining).
510    */
511   public SchemaAnnotation items(Items value) {
512      this.items = value;
513      return this;
514   }
515
516   @Override /* Schema */
517   public String maximum() {
518      return maximum;
519   }
520
521   /**
522    * Sets the <c>maximum</c> property on this annotation.
523    *
524    * @param value The new value for this property.
525    * @return This object (for method chaining).
526    */
527   public SchemaAnnotation maximum(String value) {
528      this.maximum = value;
529      return this;
530   }
531
532   @Override /* Schema */
533   public String max() {
534      return max;
535   }
536
537   /**
538    * Sets the <c>max</c> property on this annotation.
539    *
540    * @param value The new value for this property.
541    * @return This object (for method chaining).
542    */
543   public SchemaAnnotation max(String value) {
544      this.max = value;
545      return this;
546   }
547
548   @Override /* Schema */
549   public long maxItems() {
550      return maxItems;
551   }
552
553   /**
554    * Sets the <c>maxItems</c> property on this annotation.
555    *
556    * @param value The new value for this property.
557    * @return This object (for method chaining).
558    */
559   public SchemaAnnotation maxItems(long value) {
560      this.maxItems = value;
561      return this;
562   }
563
564   @Override /* Schema */
565   public long maxi() {
566      return maxi;
567   }
568
569   /**
570    * Sets the <c>maxi</c> property on this annotation.
571    *
572    * @param value The new value for this property.
573    * @return This object (for method chaining).
574    */
575   public SchemaAnnotation maxi(long value) {
576      this.maxi = value;
577      return this;
578   }
579
580   @Override /* Schema */
581   public long maxLength() {
582      return maxLength;
583   }
584
585   /**
586    * Sets the <c>maxLength</c> property on this annotation.
587    *
588    * @param value The new value for this property.
589    * @return This object (for method chaining).
590    */
591   public SchemaAnnotation maxLength(long value) {
592      this.maxLength = value;
593      return this;
594   }
595
596   @Override /* Schema */
597   public long maxl() {
598      return maxl;
599   }
600
601   /**
602    * Sets the <c>maxl</c> property on this annotation.
603    *
604    * @param value The new value for this property.
605    * @return This object (for method chaining).
606    */
607   public SchemaAnnotation maxl(long value) {
608      this.maxl = value;
609      return this;
610   }
611
612   @Override /* Schema */
613   public long maxProperties() {
614      return maxProperties;
615   }
616
617   /**
618    * Sets the <c>maxProperties</c> property on this annotation.
619    *
620    * @param value The new value for this property.
621    * @return This object (for method chaining).
622    */
623   public SchemaAnnotation maxProperties(long value) {
624      this.maxProperties = value;
625      return this;
626   }
627
628   @Override /* Schema */
629   public long maxp() {
630      return maxp;
631   }
632
633   /**
634    * Sets the <c>maxp</c> property on this annotation.
635    *
636    * @param value The new value for this property.
637    * @return This object (for method chaining).
638    */
639   public SchemaAnnotation maxp(long value) {
640      this.maxp = value;
641      return this;
642   }
643
644   @Override /* Schema */
645   public String minimum() {
646      return minimum;
647   }
648
649   /**
650    * Sets the <c>minimum</c> property on this annotation.
651    *
652    * @param value The new value for this property.
653    * @return This object (for method chaining).
654    */
655   public SchemaAnnotation minimum(String value) {
656      this.minimum = value;
657      return this;
658   }
659
660   @Override /* Schema */
661   public String min() {
662      return min;
663   }
664
665   /**
666    * Sets the <c>min</c> property on this annotation.
667    *
668    * @param value The new value for this property.
669    * @return This object (for method chaining).
670    */
671   public SchemaAnnotation min(String value) {
672      this.min = value;
673      return this;
674   }
675
676   @Override /* Schema */
677   public long minItems() {
678      return minItems;
679   }
680
681   /**
682    * Sets the <c>minItems</c> property on this annotation.
683    *
684    * @param value The new value for this property.
685    * @return This object (for method chaining).
686    */
687   public SchemaAnnotation minItems(long value) {
688      this.minItems = value;
689      return this;
690   }
691
692   @Override /* Schema */
693   public long mini() {
694      return mini;
695   }
696
697   /**
698    * Sets the <c>mini</c> property on this annotation.
699    *
700    * @param value The new value for this property.
701    * @return This object (for method chaining).
702    */
703   public SchemaAnnotation mini(long value) {
704      this.mini = value;
705      return this;
706   }
707
708   @Override /* Schema */
709   public long minLength() {
710      return minLength;
711   }
712
713   /**
714    * Sets the <c>minLength</c> property on this annotation.
715    *
716    * @param value The new value for this property.
717    * @return This object (for method chaining).
718    */
719   public SchemaAnnotation minLength(long value) {
720      this.minLength = value;
721      return this;
722   }
723
724   @Override /* Schema */
725   public long minl() {
726      return minl;
727   }
728
729   /**
730    * Sets the <c>minl</c> property on this annotation.
731    *
732    * @param value The new value for this property.
733    * @return This object (for method chaining).
734    */
735   public SchemaAnnotation minl(long value) {
736      this.minl = value;
737      return this;
738   }
739
740   @Override /* Schema */
741   public long minProperties() {
742      return minProperties;
743   }
744
745   /**
746    * Sets the <c>minProperties</c> property on this annotation.
747    *
748    * @param value The new value for this property.
749    * @return This object (for method chaining).
750    */
751   public SchemaAnnotation minProperties(long value) {
752      this.minProperties = value;
753      return this;
754   }
755
756   @Override /* Schema */
757   public long minp() {
758      return minp;
759   }
760
761   /**
762    * Sets the <c>minp</c> property on this annotation.
763    *
764    * @param value The new value for this property.
765    * @return This object (for method chaining).
766    */
767   public SchemaAnnotation minp(long value) {
768      this.minp = value;
769      return this;
770   }
771
772   @Override /* Schema */
773   public String multipleOf() {
774      return multipleOf;
775   }
776
777   /**
778    * Sets the <c>multipleOf</c> property on this annotation.
779    *
780    * @param value The new value for this property.
781    * @return This object (for method chaining).
782    */
783   public SchemaAnnotation multipleOf(String value) {
784      this.multipleOf = value;
785      return this;
786   }
787
788   @Override /* Schema */
789   public String mo() {
790      return mo;
791   }
792
793   /**
794    * Sets the <c>mo</c> property on this annotation.
795    *
796    * @param value The new value for this property.
797    * @return This object (for method chaining).
798    */
799   public SchemaAnnotation mo(String value) {
800      this.mo = value;
801      return this;
802   }
803
804   @Override /* Schema */
805   public String on() {
806      return on;
807   }
808
809   /**
810    * Sets the <c>on</c> property on this annotation.
811    *
812    * @param value The new value for this property.
813    * @return This object (for method chaining).
814    */
815   public SchemaAnnotation on(String value) {
816      this.on = value;
817      return this;
818   }
819
820   @Override /* Schema */
821   public String pattern() {
822      return pattern;
823   }
824
825   /**
826    * Sets the <c>pattern</c> property on this annotation.
827    *
828    * @param value The new value for this property.
829    * @return This object (for method chaining).
830    */
831   public SchemaAnnotation pattern(String value) {
832      this.pattern = value;
833      return this;
834   }
835
836   @Override /* Schema */
837   public String p() {
838      return p;
839   }
840
841   /**
842    * Sets the <c>p</c> property on this annotation.
843    *
844    * @param value The new value for this property.
845    * @return This object (for method chaining).
846    */
847   public SchemaAnnotation p(String value) {
848      this.p = value;
849      return this;
850   }
851
852   @Override /* Schema */
853   public String[] properties() {
854      return properties;
855   }
856
857   /**
858    * Sets the <c>properties</c> property on this annotation.
859    *
860    * @param value The new value for this property.
861    * @return This object (for method chaining).
862    */
863   public SchemaAnnotation properties(String...value) {
864      this.properties = value;
865      return this;
866   }
867
868   @Override /* Schema */
869   public boolean readOnly() {
870      return readOnly;
871   }
872
873   /**
874    * Sets the <c>readOnly</c> property on this annotation.
875    *
876    * @param value The new value for this property.
877    * @return This object (for method chaining).
878    */
879   public SchemaAnnotation readOnly(boolean value) {
880      this.readOnly = value;
881      return this;
882   }
883
884   @Override /* Schema */
885   public boolean ro() {
886      return ro;
887   }
888
889   /**
890    * Sets the <c>ro</c> property on this annotation.
891    *
892    * @param value The new value for this property.
893    * @return This object (for method chaining).
894    */
895   public SchemaAnnotation ro(boolean value) {
896      this.ro = value;
897      return this;
898   }
899
900   @Override /* Schema */
901   public boolean required() {
902      return required;
903   }
904
905   /**
906    * Sets the <c>required</c> property on this annotation.
907    *
908    * @param value The new value for this property.
909    * @return This object (for method chaining).
910    */
911   public SchemaAnnotation required(boolean value) {
912      this.required = value;
913      return this;
914   }
915
916   @Override /* Schema */
917   public boolean r() {
918      return r;
919   }
920
921   /**
922    * Sets the <c>r</c> property on this annotation.
923    *
924    * @param value The new value for this property.
925    * @return This object (for method chaining).
926    */
927   public SchemaAnnotation r(boolean value) {
928      this.r = value;
929      return this;
930   }
931
932   @Override /* Schema */
933   public String title() {
934      return title;
935   }
936
937   /**
938    * Sets the <c>title</c> property on this annotation.
939    *
940    * @param value The new value for this property.
941    * @return This object (for method chaining).
942    */
943   public SchemaAnnotation title(String value) {
944      this.title = value;
945      return this;
946   }
947
948   @Override /* Schema */
949   public String type() {
950      return type;
951   }
952
953   /**
954    * Sets the <c>type</c> property on this annotation.
955    *
956    * @param value The new value for this property.
957    * @return This object (for method chaining).
958    */
959   public SchemaAnnotation type(String value) {
960      this.type = value;
961      return this;
962   }
963
964   @Override /* Schema */
965   public String t() {
966      return t;
967   }
968
969   /**
970    * Sets the <c>t</c> property on this annotation.
971    *
972    * @param value The new value for this property.
973    * @return This object (for method chaining).
974    */
975   public SchemaAnnotation t(String value) {
976      this.t = value;
977      return this;
978   }
979
980   @Override /* Schema */
981   public boolean uniqueItems() {
982      return uniqueItems;
983   }
984
985   /**
986    * Sets the <c>uniqueItems</c> property on this annotation.
987    *
988    * @param value The new value for this property.
989    * @return This object (for method chaining).
990    */
991   public SchemaAnnotation uniqueItems(boolean value) {
992      this.uniqueItems = value;
993      return this;
994   }
995
996   @Override /* Schema */
997   public boolean ui() {
998      return ui;
999   }
1000
1001   /**
1002    * Sets the <c>ui</c> property on this annotation.
1003    *
1004    * @param value The new value for this property.
1005    * @return This object (for method chaining).
1006    */
1007   public SchemaAnnotation ui(boolean value) {
1008      this.ui = value;
1009      return this;
1010   }
1011
1012   @Override /* Schema */
1013   public String[] value() {
1014      return value;
1015   }
1016
1017   /**
1018    * Sets the <c>value</c> property on this annotation.
1019    *
1020    * @param value The new value for this property.
1021    * @return This object (for method chaining).
1022    */
1023   public SchemaAnnotation value(String...value) {
1024      this.value = value;
1025      return this;
1026   }
1027
1028   @Override /* Schema */
1029   public String[] xml() {
1030      return xml;
1031   }
1032
1033   /**
1034    * Sets the <c>xml</c> property on this annotation.
1035    *
1036    * @param value The new value for this property.
1037    * @return This object (for method chaining).
1038    */
1039   public SchemaAnnotation xml(String...value) {
1040      this.xml = value;
1041      return this;
1042   }
1043}