|
1 | 1 | package io.asfjava.ui.core.schema;
|
2 | 2 |
|
| 3 | +import java.lang.annotation.Annotation; |
| 4 | + |
3 | 5 | import com.fasterxml.jackson.databind.BeanProperty;
|
4 | 6 | import com.fasterxml.jackson.module.jsonSchema.types.StringSchema;
|
5 | 7 |
|
6 | 8 | import io.asfjava.ui.core.SchemaDecoratorFactory;
|
7 | | -import io.asfjava.ui.core.form.CheckBox; |
8 | | -import io.asfjava.ui.core.form.ComboBox; |
9 | | -import io.asfjava.ui.core.form.Password; |
10 | | -import io.asfjava.ui.core.form.RadioBox; |
11 | | -import io.asfjava.ui.core.form.TextArea; |
12 | | -import io.asfjava.ui.core.form.TextField; |
13 | 9 |
|
14 | 10 | class CustomStringSchema extends StringSchema {
|
15 | 11 |
|
16 | 12 | @Override
|
17 | 13 | public void enrichWithBeanProperty(BeanProperty beanProperty) {
|
18 | | - super.enrichWithBeanProperty(beanProperty); |
19 | | - if (beanProperty.getAnnotation(TextField.class) != null) { |
20 | | - SchemaDecoratorFactory.getInstance().getGenerator(TextField.class.getName()).customizeSchema(beanProperty, |
21 | | - this); |
22 | | - } |
23 | | - if (beanProperty.getAnnotation(ComboBox.class) != null) { |
24 | | - SchemaDecoratorFactory.getInstance().getGenerator(ComboBox.class.getName()).customizeSchema(beanProperty, |
25 | | - this); |
26 | | - } |
27 | | - if (beanProperty.getAnnotation(CheckBox.class) != null) { |
28 | | - SchemaDecoratorFactory.getInstance().getGenerator(CheckBox.class.getName()).customizeSchema(beanProperty, |
29 | | - this); |
30 | | - } |
31 | | - if (beanProperty.getAnnotation(RadioBox.class) != null) { |
32 | | - SchemaDecoratorFactory.getInstance().getGenerator(RadioBox.class.getName()).customizeSchema(beanProperty, |
33 | | - this); |
34 | | - } |
35 | | - if (beanProperty.getAnnotation(TextArea.class) != null) { |
36 | | - SchemaDecoratorFactory.getInstance().getGenerator(TextArea.class.getName()).customizeSchema(beanProperty, |
37 | | - this); |
38 | | - } |
39 | | - if (beanProperty.getAnnotation(Password.class) != null) { |
40 | | - SchemaDecoratorFactory.getInstance().getGenerator(TextField.class.getName()).customizeSchema(beanProperty, |
41 | | - this); |
42 | | - } |
| 14 | + super.enrichWithBeanProperty(beanProperty); |
| 15 | + Iterable<Annotation> it = beanProperty.getMember().annotations(); |
| 16 | + String anno = it.iterator().next().annotationType().getName(); |
| 17 | + SchemaDecoratorFactory.getInstance().getGenerator(anno).customizeSchema(beanProperty, this); |
| 18 | + |
43 | 19 | }
|
44 | 20 |
|
45 | 21 | }
|
0 commit comments