package io.asfjava.ui.core.schema;

import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.module.jsonSchema.types.StringSchema;

import io.asfjava.ui.core.SchemaDecoratorFactory;
import io.asfjava.ui.core.form.CheckBox;
import io.asfjava.ui.core.form.ComboBox;
import io.asfjava.ui.core.form.Password;
import io.asfjava.ui.core.form.RadioBox;
import io.asfjava.ui.core.form.TextArea;
import io.asfjava.ui.core.form.TextField;

class CustomStringSchema extends StringSchema {

	@Override
	public void enrichWithBeanProperty(BeanProperty beanProperty) {
		super.enrichWithBeanProperty(beanProperty);
		if (beanProperty.getAnnotation(TextField.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(TextField.class.getName()).customizeSchema(beanProperty,
					this);
		}
		if (beanProperty.getAnnotation(ComboBox.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(ComboBox.class.getName()).customizeSchema(beanProperty,
					this);
		}
		if (beanProperty.getAnnotation(CheckBox.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(CheckBox.class.getName()).customizeSchema(beanProperty,
					this);
		}
		if (beanProperty.getAnnotation(RadioBox.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(RadioBox.class.getName()).customizeSchema(beanProperty,
					this);
		}
		if (beanProperty.getAnnotation(TextArea.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(TextArea.class.getName()).customizeSchema(beanProperty,
					this);
		}
		if (beanProperty.getAnnotation(Password.class) != null) {
			SchemaDecoratorFactory.getInstance().getGenerator(TextField.class.getName()).customizeSchema(beanProperty,
					this);
		}
	}

}

@@ -25,24 +25,65 @@
 re.schema;%0A%0A
+import java.lang.annotation.Annotation;%0A%0A
 import com.f
@@ -243,255 +243,8 @@
 ory;
-%0Aimport io.asfjava.ui.core.form.CheckBox;%0Aimport io.asfjava.ui.core.form.ComboBox;%0Aimport io.asfjava.ui.core.form.Password;%0Aimport io.asfjava.ui.core.form.RadioBox;%0Aimport io.asfjava.ui.core.form.TextArea;%0Aimport io.asfjava.ui.core.form.TextField;
 %0A%0Acl
@@ -415,997 +415,143 @@
 ty);
+%09
 %0A%09%09
-if (beanProperty.getAnnotation(TextField.class) != null) %7B%0A%09%09%09SchemaDecoratorFactory.getInstance().getGenerator(TextField.class.getName()).customizeSchema(beanProperty,%0A%09%09%09%09%09this);%0A%09%09%7D%0A%09%09if (beanProperty.getAnnotation(ComboBox.class) != null) %7B%0A%09%09%09SchemaDecoratorFactory.getInstance().getGenerator(ComboBox.class.getName()).customizeSchema(beanProperty,%0A%09%09%09%09%09this);%0A%09%09%7D%0A%09%09if (beanProperty.getAnnotation(CheckBox.class) != null) %7B%0A%09%09%09SchemaDecoratorFactory.getInstance().getGenerator(CheckBox.class.getName()).customizeSchema(beanProperty,%0A%09%09%09%09%09this);%0A%09%09%7D%0A%09%09if (beanProperty.getAnnotation(RadioBox.class) != null) %7B%0A%09%09%09SchemaDecoratorFactory.getInstance().getGenerator(RadioBox.class.getName()).customizeSchema(beanProperty,%0A%09%09%09%09%09this);%0A%09%09%7D%0A%09%09if (beanProperty.getAnnotation(TextArea.class) != null) %7B%0A%09%09%09SchemaDecoratorFactory.getInstance().getGenerator(TextArea.class.getName()).customizeSchema(beanProperty,%0A%09%09%09%09%09this);%0A%09%09%7D%0A%09%09if (beanProperty.getAnnotation(Password.class) != null) %7B%0A%09
+Iterable%3CAnnotation%3E it = beanProperty.getMember().annotations();%0A%09%09String anno = it.iterator().next().annotationType().getName();%0A
 %09%09Sc
@@ -602,33 +602,12 @@
 tor(
-TextField.class.getName()
+anno
 ).cu
@@ -637,24 +637,16 @@
 rty,
-%0A%09%09%09%09%09
+ 
 this);%0A
-%09%09%7D
 %0A%09%7D%0A

edit the CustomStringSchema in order to ietrate on annotations