Search in sources :

Example 1 with ConnectorTypologyConverter

use of org.talend.components.service.rest.dto.ConnectorTypologyConverter in project components by Talend.

the class ControllersConfiguration method initBinder.

/**
 * Initialise Web binders to be able to use {@link PropertyTrigger} in camel case in {@link PathVariable}.
 */
@InitBinder
protected void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(PropertyTrigger.class, new PropertyEditorSupport() {

        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            String upperUnderscoreCased = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE).convert(text);
            PropertyTrigger propertyTrigger = PropertyTrigger.valueOf(upperUnderscoreCased);
            setValue(propertyTrigger);
        }
    });
    binder.registerCustomEditor(DefinitionType.class, new DefinitionTypeConverter());
    binder.registerCustomEditor(ConnectorTypology.class, new ConnectorTypologyConverter());
}
Also used : DefinitionTypeConverter(org.talend.components.service.rest.DefinitionTypeConverter) ConnectorTypologyConverter(org.talend.components.service.rest.dto.ConnectorTypologyConverter) PropertyTrigger(org.talend.daikon.serialize.jsonschema.PropertyTrigger) PropertyEditorSupport(java.beans.PropertyEditorSupport) InitBinder(org.springframework.web.bind.annotation.InitBinder)

Aggregations

PropertyEditorSupport (java.beans.PropertyEditorSupport)1 InitBinder (org.springframework.web.bind.annotation.InitBinder)1 DefinitionTypeConverter (org.talend.components.service.rest.DefinitionTypeConverter)1 ConnectorTypologyConverter (org.talend.components.service.rest.dto.ConnectorTypologyConverter)1 PropertyTrigger (org.talend.daikon.serialize.jsonschema.PropertyTrigger)1