@@ -120,24 +120,24 @@ public static String getSchemaTypeFor(TypeRef typeRef) {
120120 }
121121
122122 protected static class SchemaPropsOptions {
123- final Optional < Double > min ;
124- final Optional < Double > max ;
125- final Optional < String > pattern ;
123+ final Double min ;
124+ final Double max ;
125+ final String pattern ;
126126 final boolean nullable ;
127127 final boolean required ;
128128
129129 final boolean preserveUnknownFields ;
130130
131131 SchemaPropsOptions () {
132- min = Optional . empty () ;
133- max = Optional . empty () ;
134- pattern = Optional . empty () ;
132+ min = null ;
133+ max = null ;
134+ pattern = null ;
135135 nullable = false ;
136136 required = false ;
137137 preserveUnknownFields = false ;
138138 }
139139
140- public SchemaPropsOptions (Optional < Double > min , Optional < Double > max , Optional < String > pattern ,
140+ public SchemaPropsOptions (Double min , Double max , String pattern ,
141141 boolean nullable , boolean required , boolean preserveUnknownFields ) {
142142 this .min = min ;
143143 this .max = max ;
@@ -148,15 +148,15 @@ public SchemaPropsOptions(Optional<Double> min, Optional<Double> max, Optional<S
148148 }
149149
150150 public Optional <Double > getMin () {
151- return min ;
151+ return Optional . ofNullable ( min ) ;
152152 }
153153
154154 public Optional <Double > getMax () {
155- return max ;
155+ return Optional . ofNullable ( max ) ;
156156 }
157157
158158 public Optional <String > getPattern () {
159- return pattern ;
159+ return Optional . ofNullable ( pattern ) ;
160160 }
161161
162162 public boolean isNullable () {
@@ -290,7 +290,7 @@ private T internalFromImpl(TypeDef definition, Set<String> visited, InternalSche
290290 facade .pattern ,
291291 facade .nullable ,
292292 facade .required ,
293- facade .preserveSelfUnknownFields );
293+ facade .preserveUnknownFields );
294294
295295 addProperty (possiblyRenamedProperty , builder , possiblyUpdatedSchema , options );
296296 }
@@ -313,14 +313,13 @@ private static class PropertyOrAccessor {
313313 private final String propertyName ;
314314 private final String type ;
315315 private String renamedTo ;
316- private Optional < Double > min ;
317- private Optional < Double > max ;
318- private Optional < String > pattern ;
316+ private Double min ;
317+ private Double max ;
318+ private String pattern ;
319319 private boolean nullable ;
320320 private boolean required ;
321321 private boolean ignored ;
322322 private boolean preserveUnknownFields ;
323- private boolean preserveSelfUnknownFields ;
324323 private String description ;
325324 private TypeRef schemaFrom ;
326325
@@ -329,10 +328,6 @@ private PropertyOrAccessor(Collection<AnnotationRef> annotations, String name, S
329328 this .name = name ;
330329 this .propertyName = propertyName ;
331330 type = isMethod ? "accessor" : "field" ;
332-
333- min = Optional .empty ();
334- max = Optional .empty ();
335- pattern = Optional .empty ();
336331 }
337332
338333 static PropertyOrAccessor fromProperty (Property property ) {
@@ -350,13 +345,13 @@ public void process() {
350345 nullable = true ;
351346 break ;
352347 case ANNOTATION_MAX :
353- max = Optional . of (( Double ) a .getParameters ().get (VALUE ) );
348+ max = ( Double ) a .getParameters ().get (VALUE );
354349 break ;
355350 case ANNOTATION_MIN :
356- min = Optional . of (( Double ) a .getParameters ().get (VALUE ) );
351+ min = ( Double ) a .getParameters ().get (VALUE );
357352 break ;
358353 case ANNOTATION_PATTERN :
359- pattern = Optional . of (( String ) a .getParameters ().get (VALUE ) );
354+ pattern = ( String ) a .getParameters ().get (VALUE );
360355 break ;
361356 case ANNOTATION_NOT_NULL :
362357 LOGGER .warn ("Annotation: {} on property: {} is deprecated. Please use: {} instead" , ANNOTATION_NOT_NULL , name ,
@@ -383,10 +378,8 @@ public void process() {
383378 break ;
384379 case ANNOTATION_JSON_ANY_GETTER :
385380 case ANNOTATION_JSON_ANY_SETTER :
386- preserveUnknownFields = true ;
387- break ;
388381 case ANNOTATION_PERSERVE_UNKNOWN_FIELDS :
389- preserveSelfUnknownFields = true ;
382+ preserveUnknownFields = true ;
390383 break ;
391384 case ANNOTATION_SCHEMA_FROM :
392385 schemaFrom = extractClassRef (a .getParameters ().get ("type" ));
@@ -404,15 +397,15 @@ public boolean isNullable() {
404397 }
405398
406399 public Optional <Double > getMax () {
407- return max ;
400+ return Optional . ofNullable ( max ) ;
408401 }
409402
410403 public Optional <Double > getMin () {
411- return min ;
404+ return Optional . ofNullable ( min ) ;
412405 }
413406
414407 public Optional <String > getPattern () {
415- return pattern ;
408+ return Optional . ofNullable ( pattern ) ;
416409 }
417410
418411 public boolean isRequired () {
@@ -427,10 +420,6 @@ public boolean isPreserveUnknownFields() {
427420 return preserveUnknownFields ;
428421 }
429422
430- public boolean isPreserveSelfUnknownFields () {
431- return preserveSelfUnknownFields ;
432- }
433-
434423 public String getDescription () {
435424 return description ;
436425 }
@@ -461,14 +450,13 @@ private static class PropertyFacade {
461450 private final List <PropertyOrAccessor > propertyOrAccessors = new ArrayList <>(4 );
462451 private String renamedTo ;
463452 private String description ;
464- private Optional < Double > min ;
465- private Optional < Double > max ;
466- private Optional < String > pattern ;
453+ private Double min ;
454+ private Double max ;
455+ private String pattern ;
467456 private boolean nullable ;
468457 private boolean required ;
469458 private boolean ignored ;
470459 private boolean preserveUnknownFields ;
471- private boolean preserveSelfUnknownFields ;
472460 private final Property original ;
473461 private String nameContributedBy ;
474462 private String descriptionContributedBy ;
@@ -492,9 +480,9 @@ public PropertyFacade(Property property, Map<String, Method> potentialAccessors,
492480 propertyOrAccessors .add (PropertyOrAccessor .fromMethod (method , name ));
493481 }
494482 schemaFrom = schemaSwap ;
495- min = Optional . empty () ;
496- max = Optional . empty () ;
497- pattern = Optional . empty () ;
483+ min = null ;
484+ max = null ;
485+ pattern = null ;
498486 }
499487
500488 public Property process () {
@@ -520,18 +508,9 @@ public Property process() {
520508 LOGGER .debug ("Description for property {} has already been contributed by: {}" , name , descriptionContributedBy );
521509 }
522510 }
523-
524- if (p .getMin ().isPresent ()) {
525- min = p .getMin ();
526- }
527-
528- if (p .getMax ().isPresent ()) {
529- max = p .getMax ();
530- }
531-
532- if (p .getPattern ().isPresent ()) {
533- pattern = p .getPattern ();
534- }
511+ min = p .getMin ().orElse (min );
512+ max = p .getMax ().orElse (max );
513+ pattern = p .getPattern ().orElse (pattern );
535514
536515 if (p .isNullable ()) {
537516 nullable = true ;
@@ -543,13 +522,7 @@ public Property process() {
543522 ignored = true ;
544523 }
545524
546- if (p .isPreserveUnknownFields ()) {
547- preserveUnknownFields = true ;
548- }
549-
550- if (p .isPreserveSelfUnknownFields ()) {
551- preserveSelfUnknownFields = true ;
552- }
525+ preserveUnknownFields = p .isPreserveUnknownFields () || preserveUnknownFields ;
553526
554527 if (p .contributeSchemaFrom ()) {
555528 schemaFrom = p .getSchemaFrom ();
0 commit comments