11package io .asfjava .ui .core .schema .decorators ;
22
3+ import java .util .Optional ;
4+
35import com .fasterxml .jackson .databind .BeanProperty ;
46import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
57import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
@@ -10,19 +12,20 @@ public class PasswordSchemaDecorator implements SchemaDecorator {
1012
1113 @ Override
1214 public void customizeSchema (BeanProperty property , JsonSchema jsonschema ) {
13- Password annotation = property .getAnnotation (Password .class );
14- if (annotation != null && annotation .title () != null ) {
15- ((StringSchema ) jsonschema ).setTitle (annotation .title ());
16- }
17- if (annotation .pattern () != null ) {
18- ((StringSchema ) jsonschema ).setPattern (annotation .pattern ());
19- }
20- if (annotation .minLenght () != 0 ) {
21- ((StringSchema ) jsonschema ).setMinLength (annotation .minLenght ());
22- }
23- if (annotation .maxLenght () != Integer .MAX_VALUE ) {
24- ((StringSchema ) jsonschema ).setMaxLength (annotation .maxLenght ());
25- }
15+ Optional .ofNullable (property .getAnnotation (Password .class )).ifPresent (annotation -> {
16+ if (annotation .title () != null ) {
17+ ((StringSchema ) jsonschema ).setTitle (annotation .title ());
18+ }
19+ if (annotation .pattern () != null ) {
20+ ((StringSchema ) jsonschema ).setPattern (annotation .pattern ());
21+ }
22+ if (annotation .minLenght () != 0 ) {
23+ ((StringSchema ) jsonschema ).setMinLength (annotation .minLenght ());
24+ }
25+ if (annotation .maxLenght () != Integer .MAX_VALUE ) {
26+ ((StringSchema ) jsonschema ).setMaxLength (annotation .maxLenght ());
27+ }
28+ });
2629 }
2730
2831 @ Override
0 commit comments