@@ -3903,28 +3903,30 @@ public record EnumSchemaOption( // @formatter:off
39033903 @ JsonProperty ("const" ) String constValue ,
39043904 @ JsonProperty ("title" ) String title ) { // @formatter:on
39053905
3906- public static Builder builder (String constValue , String title ) {
3907- return new Builder (constValue , title );
3906+ public EnumSchemaOption {
3907+ Assert .notNull (constValue , "constValue must not be null" );
3908+ Assert .notNull (title , "title must not be null" );
39083909 }
39093910
3910- public static class Builder {
3911-
3912- private final String constValue ;
3913-
3914- private final String title ;
3915-
3916- private Builder ( String constValue , String title ) {
3917- Assert . notNull ( constValue , "constValue must not be null" ) ;
3918- Assert . notNull ( title , "title must not be null" );
3919- this . constValue = constValue ;
3920- this . title = title ;
3921- }
3922-
3923- public EnumSchemaOption build () {
3924- return new EnumSchemaOption ( constValue , title );
3911+ @ JsonCreator
3912+ static EnumSchemaOption fromJson ( @ JsonProperty ( "const" ) String constValue ,
3913+ @ JsonProperty ( "title" ) String title ) {
3914+ if ( constValue == null || title == null ) {
3915+ List < String > missing = new ArrayList <>() ;
3916+ if ( constValue == null ) {
3917+ missing . add ( " constValue -> ''" );
3918+ constValue = "" ;
3919+ }
3920+ if ( title == null ) {
3921+ missing . add ( " title -> ''" ) ;
3922+ title = "" ;
3923+ }
3924+ logger . warn ( " EnumSchemaOption: missing required fields during deserialization: {}" ,
3925+ String . join ( ", " , missing ) );
39253926 }
3926-
3927+ return new EnumSchemaOption ( constValue , title );
39273928 }
3929+
39283930 }
39293931
39303932 /**
@@ -3950,7 +3952,7 @@ public record LegacyTitledEnumSchema( // @formatter:off
39503952 @ JsonProperty ("default" ) String defaultValue ) { // @formatter:on
39513953
39523954 public LegacyTitledEnumSchema {
3953- Assert .notNull (enumValues , "enum must not be null" );
3955+ Assert .notNull (enumValues , "enumValues must not be null" );
39543956 }
39553957
39563958 @ JsonProperty ("type" )
@@ -3988,40 +3990,26 @@ public Builder description(String description) {
39883990 }
39893991
39903992 public Builder enumValues (List <String > enumValues ) {
3991- Assert .notNull (enumValues , "enum must not be null" );
3993+ Assert .notNull (enumValues , "enumValues must not be null" );
39923994 this .enumValues = new ArrayList <>(enumValues );
39933995 return this ;
39943996 }
39953997
39963998 public Builder enumValues (String ... enumValues ) {
3997- Assert .notNull (enumValues , "enum must not be null" );
3998- this .enumValues = new ArrayList <>(Arrays .asList (enumValues ));
3999- return this ;
4000- }
4001-
4002- public Builder enumValue (String enumValue ) {
4003- if (this .enumValues == null ) {
4004- this .enumValues = new ArrayList <>();
4005- }
4006- this .enumValues .add (enumValue );
3999+ Assert .notNull (enumValues , "enumValues must not be null" );
4000+ this .enumValues = Arrays .asList (enumValues );
40074001 return this ;
40084002 }
40094003
40104004 public Builder enumNames (List <String > enumNames ) {
4011- this .enumNames = enumNames == null ? null : new ArrayList <>(enumNames );
4005+ Assert .notNull (enumNames , "enumNames must not be null" );
4006+ this .enumNames = new ArrayList <>(enumNames );
40124007 return this ;
40134008 }
40144009
40154010 public Builder enumNames (String ... enumNames ) {
4016- this .enumNames = enumNames == null ? null : new ArrayList <>(Arrays .asList (enumNames ));
4017- return this ;
4018- }
4019-
4020- public Builder enumName (String enumName ) {
4021- if (this .enumNames == null ) {
4022- this .enumNames = new ArrayList <>();
4023- }
4024- this .enumNames .add (enumName );
4011+ Assert .notNull (enumNames , "enumNames must not be null" );
4012+ this .enumNames = Arrays .asList (enumNames );
40254013 return this ;
40264014 }
40274015
@@ -4031,7 +4019,7 @@ public Builder defaultValue(String defaultValue) {
40314019 }
40324020
40334021 public LegacyTitledEnumSchema build () {
4034- Assert .notEmpty (enumValues , "enum must not be empty" );
4022+ Assert .notEmpty (enumValues , "enumValues must not be empty" );
40354023 return new LegacyTitledEnumSchema (title , description , enumValues , enumNames , defaultValue );
40364024 }
40374025
@@ -4055,7 +4043,7 @@ public record UntitledSingleSelectEnumSchema( // @formatter:off
40554043 @ JsonProperty ("default" ) String defaultValue ) { // @formatter:on
40564044
40574045 public UntitledSingleSelectEnumSchema {
4058- Assert .notNull (enumValues , "enum must not be null" );
4046+ Assert .notNull (enumValues , "enumValues must not be null" );
40594047 }
40604048
40614049 @ JsonProperty ("type" )
@@ -4091,22 +4079,14 @@ public Builder description(String description) {
40914079 }
40924080
40934081 public Builder enumValues (List <String > enumValues ) {
4094- Assert .notNull (enumValues , "enum must not be null" );
4082+ Assert .notNull (enumValues , "enumValues must not be null" );
40954083 this .enumValues = new ArrayList <>(enumValues );
40964084 return this ;
40974085 }
40984086
40994087 public Builder enumValues (String ... enumValues ) {
4100- Assert .notNull (enumValues , "enum must not be null" );
4101- this .enumValues = new ArrayList <>(Arrays .asList (enumValues ));
4102- return this ;
4103- }
4104-
4105- public Builder enumValue (String enumValue ) {
4106- if (this .enumValues == null ) {
4107- this .enumValues = new ArrayList <>();
4108- }
4109- this .enumValues .add (enumValue );
4088+ Assert .notNull (enumValues , "enumValues must not be null" );
4089+ this .enumValues = Arrays .asList (enumValues );
41104090 return this ;
41114091 }
41124092
@@ -4116,7 +4096,7 @@ public Builder defaultValue(String defaultValue) {
41164096 }
41174097
41184098 public UntitledSingleSelectEnumSchema build () {
4119- Assert .notEmpty (enumValues , "enum must not be empty" );
4099+ Assert .notEmpty (enumValues , "enumValues must not be empty" );
41204100 return new UntitledSingleSelectEnumSchema (title , description , enumValues , defaultValue );
41214101 }
41224102
@@ -4184,15 +4164,7 @@ public Builder oneOf(List<EnumSchemaOption> oneOf) {
41844164
41854165 public Builder oneOf (EnumSchemaOption ... oneOf ) {
41864166 Assert .notNull (oneOf , "oneOf must not be null" );
4187- this .oneOf = new ArrayList <>(Arrays .asList (oneOf ));
4188- return this ;
4189- }
4190-
4191- public Builder addOneOf (EnumSchemaOption option ) {
4192- if (this .oneOf == null ) {
4193- this .oneOf = new ArrayList <>();
4194- }
4195- this .oneOf .add (option );
4167+ this .oneOf = Arrays .asList (oneOf );
41964168 return this ;
41974169 }
41984170
@@ -4221,7 +4193,7 @@ public record UntitledMultiSelectItems( // @formatter:off
42214193 @ JsonProperty ("enum" ) List <String > enumValues ) { // @formatter:on
42224194
42234195 public UntitledMultiSelectItems {
4224- Assert .notNull (enumValues , "enum must not be null" );
4196+ Assert .notNull (enumValues , "enumValues must not be null" );
42254197 }
42264198
42274199 @ JsonProperty ("type" )
@@ -4241,27 +4213,19 @@ private Builder() {
42414213 }
42424214
42434215 public Builder enumValues (List <String > enumValues ) {
4244- Assert .notNull (enumValues , "enum must not be null" );
4216+ Assert .notNull (enumValues , "enumValues must not be null" );
42454217 this .enumValues = new ArrayList <>(enumValues );
42464218 return this ;
42474219 }
42484220
42494221 public Builder enumValues (String ... enumValues ) {
4250- Assert .notNull (enumValues , "enum must not be null" );
4251- this .enumValues = new ArrayList <>(Arrays .asList (enumValues ));
4252- return this ;
4253- }
4254-
4255- public Builder enumValue (String enumValue ) {
4256- if (this .enumValues == null ) {
4257- this .enumValues = new ArrayList <>();
4258- }
4259- this .enumValues .add (enumValue );
4222+ Assert .notNull (enumValues , "enumValues must not be null" );
4223+ this .enumValues = Arrays .asList (enumValues );
42604224 return this ;
42614225 }
42624226
42634227 public UntitledMultiSelectItems build () {
4264- Assert .notEmpty (enumValues , "enum must not be empty" );
4228+ Assert .notEmpty (enumValues , "enumValues must not be empty" );
42654229 return new UntitledMultiSelectItems (enumValues );
42664230 }
42674231
@@ -4346,16 +4310,15 @@ public Builder maxItems(Integer maxItems) {
43464310 return this ;
43474311 }
43484312
4349- public Builder defaultValue (List <String > defaultValue ) {
4350- this .defaultValue = defaultValue == null ? null : new ArrayList <>(defaultValue );
4313+ public Builder defaults (String ... defaultValue ) {
4314+ Assert .notNull (defaultValue , "defaultValue must not be null" );
4315+ this .defaultValue = Arrays .asList (defaultValue );
43514316 return this ;
43524317 }
43534318
4354- public Builder addDefaultValue (String defaultValue ) {
4355- if (this .defaultValue == null ) {
4356- this .defaultValue = new ArrayList <>();
4357- }
4358- this .defaultValue .add (defaultValue );
4319+ public Builder defaults (List <String > defaultValue ) {
4320+ Assert .notNull (defaultValue , "defaultValue must not be null" );
4321+ this .defaultValue = new ArrayList <>(defaultValue );
43594322 return this ;
43604323 }
43614324
@@ -4401,15 +4364,7 @@ public Builder anyOf(List<EnumSchemaOption> anyOf) {
44014364
44024365 public Builder anyOf (EnumSchemaOption ... anyOf ) {
44034366 Assert .notNull (anyOf , "anyOf must not be null" );
4404- this .anyOf = new ArrayList <>(Arrays .asList (anyOf ));
4405- return this ;
4406- }
4407-
4408- public Builder addAnyOf (EnumSchemaOption option ) {
4409- if (this .anyOf == null ) {
4410- this .anyOf = new ArrayList <>();
4411- }
4412- this .anyOf .add (option );
4367+ this .anyOf = Arrays .asList (anyOf );
44134368 return this ;
44144369 }
44154370
@@ -4499,16 +4454,15 @@ public Builder maxItems(Integer maxItems) {
44994454 return this ;
45004455 }
45014456
4502- public Builder defaultValue (List <String > defaultValue ) {
4503- this .defaultValue = defaultValue == null ? null : new ArrayList <>(defaultValue );
4457+ public Builder defaults (List <String > defaultValue ) {
4458+ Assert .notNull (defaultValue , "defaultValue must not be null" );
4459+ this .defaultValue = new ArrayList <>(defaultValue );
45044460 return this ;
45054461 }
45064462
4507- public Builder addDefaultValue (String defaultValue ) {
4508- if (this .defaultValue == null ) {
4509- this .defaultValue = new ArrayList <>();
4510- }
4511- this .defaultValue .add (defaultValue );
4463+ public Builder defaults (String ... defaultValue ) {
4464+ Assert .notNull (defaultValue , "defaultValue must not be null" );
4465+ this .defaultValue = Arrays .asList (defaultValue );
45124466 return this ;
45134467 }
45144468
0 commit comments