1
1
package io .asfjava .ui .core .schema .decorators ;
2
2
3
+ import java .util .Optional ;
4
+
3
5
import com .fasterxml .jackson .databind .BeanProperty ;
4
6
import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
5
7
import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
@@ -10,19 +12,20 @@ public class PasswordSchemaDecorator implements SchemaDecorator {
10
12
11
13
@ Override
12
14
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
+ });
26
29
}
27
30
28
31
@ Override
0 commit comments