File tree Expand file tree Collapse file tree 5 files changed +67
-8
lines changed
src/main/java/io/asfjava/ui/core/schema Expand file tree Collapse file tree 5 files changed +67
-8
lines changed Original file line number Diff line number Diff line change 1+ package io .asfjava .ui .core .schema ;
2+
3+ import com .fasterxml .jackson .databind .BeanProperty ;
4+ import com .fasterxml .jackson .module .jsonSchema .types .IntegerSchema ;
5+
6+ class CustomIntegerSchema extends IntegerSchema {
7+ @ Override
8+ public void enrichWithBeanProperty (BeanProperty beanProperty ) {
9+ super .enrichWithBeanProperty (beanProperty );
10+ SchemaDecoratorUtil .get ().decorate (beanProperty , this );
11+ }
12+ }
Original file line number Diff line number Diff line change 11package io .asfjava .ui .core .schema ;
22
33import com .fasterxml .jackson .module .jsonSchema .factories .JsonSchemaFactory ;
4+ import com .fasterxml .jackson .module .jsonSchema .types .IntegerSchema ;
5+ import com .fasterxml .jackson .module .jsonSchema .types .NumberSchema ;
46import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
57
68class CustomJsonSchemaFactory extends JsonSchemaFactory {
79 @ Override
810 public StringSchema stringSchema () {
911 return new CustomStringSchema ();
1012 }
13+
14+ @ Override
15+ public NumberSchema numberSchema () {
16+ return new CustomNumberSchema ();
17+ }
18+
19+ @ Override
20+ public IntegerSchema integerSchema () {
21+ return new CustomIntegerSchema ();
22+ }
1123}
Original file line number Diff line number Diff line change 1+ package io .asfjava .ui .core .schema ;
2+
3+ import com .fasterxml .jackson .databind .BeanProperty ;
4+ import com .fasterxml .jackson .module .jsonSchema .types .NumberSchema ;
5+
6+ class CustomNumberSchema extends NumberSchema {
7+ @ Override
8+ public void enrichWithBeanProperty (BeanProperty beanProperty ) {
9+ super .enrichWithBeanProperty (beanProperty );
10+ SchemaDecoratorUtil .get ().decorate (beanProperty , this );
11+ }
12+ }
Original file line number Diff line number Diff line change 11package io .asfjava .ui .core .schema ;
22
3- import java .lang .annotation .Annotation ;
4-
53import com .fasterxml .jackson .databind .BeanProperty ;
64import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
75
8- import io .asfjava .ui .core .SchemaDecoratorFactory ;
9-
106class CustomStringSchema extends StringSchema {
117
128 @ Override
139 public void enrichWithBeanProperty (BeanProperty beanProperty ) {
1410 super .enrichWithBeanProperty (beanProperty );
15- Iterable <Annotation > it = beanProperty .getMember ().annotations ();
16- it .forEach (
17- annotation -> SchemaDecoratorFactory .getInstance ().getDecorator (annotation .annotationType ().getName ())
18- .ifPresent (decorator -> decorator .customizeSchema (beanProperty , this )));
11+ SchemaDecoratorUtil .get ().decorate (beanProperty , this );
1912 }
2013
2114}
Original file line number Diff line number Diff line change 1+ package io .asfjava .ui .core .schema ;
2+
3+ import java .lang .annotation .Annotation ;
4+
5+ import com .fasterxml .jackson .databind .BeanProperty ;
6+ import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
7+
8+ import io .asfjava .ui .core .SchemaDecoratorFactory ;
9+
10+ final class SchemaDecoratorUtil {
11+
12+ void decorate (BeanProperty beanProperty , JsonSchema simpleTypeSchema ) {
13+ Iterable <Annotation > it = beanProperty .getMember ().annotations ();
14+ it .forEach (
15+ annotation -> SchemaDecoratorFactory .getInstance ().getDecorator (annotation .annotationType ().getName ())
16+ .ifPresent (decorator -> decorator .customizeSchema (beanProperty , simpleTypeSchema )));
17+ }
18+
19+ static SchemaDecoratorUtil get () {
20+ if (instance == null ) {
21+ instance = new SchemaDecoratorUtil ();
22+ }
23+ return instance ;
24+ }
25+
26+ private static SchemaDecoratorUtil instance ;
27+
28+ private SchemaDecoratorUtil () {
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments