dimanche 13 février 2022

How to set public data in Strategy Pattern

I am making a custom flow form function, including flow and form, with various controls in the form (including, single line text, number input box, date input box, etc.), and the properties of each control are different, so I need to deal with receiving parameters and echo

I used MAP to receive irregular properties, and used Strategy Pattern to make a converter for each control, converting the MAP into a corresponding control object

public interface FormWidgetRequestConverter<T extends WidgetProperties>  extends MapConverter<T>, FormWidget {
@Component

public class WidgetEmailRequestConverter implements FormWidgetRequestConverter<WidgetEmail>{

    @Override
    public WidgetEmail convert(LinkedHashMap<String, Object> source) {
        return JacksonUtils.convertValue(source, WidgetEmail.class);
    }

    @Override
    public FormWidgetTypeEnum getType() {
        return FormWidgetTypeEnum.EMAIL;
    }

}

Now I want to optimize (that is, when there are 10 identical controls, it is necessary to extract these 10 identical attributes into parameters for batch query, and then set them back, so that there is no need to query again every time a control is dropped, it is actually the same Inquire)

What can i do

Aucun commentaire:

Enregistrer un commentaire