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 5
5
6
6
public final class ASFUILogger {
7
7
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 () {
10
11
return LOGGER ;
11
12
}
12
-
13
+
13
14
private ASFUILogger () {
14
15
}
15
16
Original file line number Diff line number Diff line change 1
1
package io .asfjava .ui .core .logging ;
2
2
3
3
public 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
+ }
9
10
}
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 1
1
package io .asfjava .ui .core .schema ;
2
2
3
3
import 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 ;
4
6
import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
5
7
6
8
class CustomJsonSchemaFactory extends JsonSchemaFactory {
7
9
@ Override
8
10
public StringSchema stringSchema () {
9
11
return new CustomStringSchema ();
10
12
}
13
+
14
+ @ Override
15
+ public NumberSchema numberSchema () {
16
+ return new CustomNumberSchema ();
17
+ }
18
+
19
+ @ Override
20
+ public IntegerSchema integerSchema () {
21
+ return new CustomIntegerSchema ();
22
+ }
11
23
}
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 8
8
class CustomSchemaFactoryWrapper extends SchemaFactoryWrapper {
9
9
10
10
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
- }
19
11
20
12
@ Override
21
13
public SchemaFactoryWrapper getWrapper (SerializerProvider p , VisitorContext rvc ) {
Original file line number Diff line number Diff line change 1
1
package io .asfjava .ui .core .schema ;
2
2
3
- import java .lang .annotation .Annotation ;
4
-
5
3
import com .fasterxml .jackson .databind .BeanProperty ;
6
4
import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
7
5
8
- import io .asfjava .ui .core .SchemaDecoratorFactory ;
9
-
10
6
class CustomStringSchema extends StringSchema {
11
7
12
8
@ Override
13
9
public void enrichWithBeanProperty (BeanProperty beanProperty ) {
14
10
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 );
19
12
}
20
13
21
14
}
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 2
2
3
3
import com .fasterxml .jackson .databind .BeanProperty ;
4
4
import com .fasterxml .jackson .module .jsonSchema .JsonSchema ;
5
- import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
5
+ import com .fasterxml .jackson .module .jsonSchema .types .SimpleTypeSchema ;
6
6
7
7
import io .asfjava .ui .core .form .Number ;
8
8
@@ -12,7 +12,7 @@ public class NumberSchemaDecorator implements SchemaDecorator {
12
12
public void customizeSchema (BeanProperty property , JsonSchema jsonschema ) {
13
13
Number annotation = property .getAnnotation (Number .class );
14
14
if (annotation != null && annotation .title () != null ) {
15
- ((StringSchema ) jsonschema ).setTitle (annotation .title ());
15
+ ((SimpleTypeSchema ) jsonschema ).setTitle (annotation .title ());
16
16
}
17
17
}
18
18
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ public class UiForm implements Serializable {
11
11
private ArrayNode form ;
12
12
13
13
public UiForm (JsonSchema schema , ArrayNode form ) {
14
- this . schema = schema ;
15
- this . form = form ;
14
+ setSchema ( schema ) ;
15
+ setForm ( form ) ;
16
16
}
17
17
18
18
public JsonSchema getSchema () {
You can’t perform that action at this time.
0 commit comments