File tree Expand file tree Collapse file tree 11 files changed +275
-136
lines changed
test/java/io/asfjava/ui/core/schema Expand file tree Collapse file tree 11 files changed +275
-136
lines changed Original file line number Diff line number Diff line change 55
66public final class ASFUILogger {
77
8- private final static Logger LOGGER =LoggerFactory .getLogger ("ASFUILogger" );
9- public static Logger getLogger (){
8+ private final static Logger LOGGER = LoggerFactory .getLogger ("ASFUILogger" );
9+
10+ public static Logger getLogger () {
1011 return LOGGER ;
1112 }
12-
13+
1314 private ASFUILogger () {
1415 }
1516
Original file line number Diff line number Diff line change 11package io .asfjava .ui .core .logging ;
22
33public final class ErrorCode {
4- public final static String ASF01 ="Failure when trying to load Generators" ;
5- public final static String ASF02 ="Failure when trying to load Decorators" ;
6- private ErrorCode (){
7-
8- }
4+ public final static String ASF01 = "Failure when trying to load Generators" ;
5+ public final static String ASF02 = "Failure when trying to load Decorators" ;
6+
7+ private ErrorCode () {
8+
9+ }
910}
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 88class CustomSchemaFactoryWrapper extends SchemaFactoryWrapper {
99
1010 private static class SFSchemaFactoryWrapperFactory extends WrapperFactory {
11- @ Override
12- public SchemaFactoryWrapper getWrapper (SerializerProvider p ) {
13- SchemaFactoryWrapper wrapper = new CustomSchemaFactoryWrapper ();
14- if (p != null ) {
15- wrapper .setProvider (p );
16- }
17- return wrapper ;
18- }
1911
2012 @ Override
2113 public SchemaFactoryWrapper getWrapper (SerializerProvider p , VisitorContext rvc ) {
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+ }
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .databind .BeanProperty ;
44import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
5- import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
5+ import com .fasterxml .jackson .module .jsonSchema .types .SimpleTypeSchema ;
66
77import io .asfjava .ui .core .form .Number ;
88
@@ -12,7 +12,7 @@ public class NumberSchemaDecorator implements SchemaDecorator {
1212 public void customizeSchema (BeanProperty property , JsonSchema jsonschema ) {
1313 Number annotation = property .getAnnotation (Number .class );
1414 if (annotation != null && annotation .title () != null ) {
15- ((StringSchema ) jsonschema ).setTitle (annotation .title ());
15+ ((SimpleTypeSchema ) jsonschema ).setTitle (annotation .title ());
1616 }
1717 }
1818
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ public class UiForm implements Serializable {
1111 private ArrayNode form ;
1212
1313 public UiForm (JsonSchema schema , ArrayNode form ) {
14- this . schema = schema ;
15- this . form = form ;
14+ setSchema ( schema ) ;
15+ setForm ( form ) ;
1616 }
1717
1818 public JsonSchema getSchema () {
You can’t perform that action at this time.
0 commit comments