All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bklab.flow.convertor.StringToIntConverter Maven / Gradle / Ivy

There is a newer version: 22.0.1
Show newest version
package org.bklab.flow.convertor;

import com.vaadin.flow.data.binder.Result;
import com.vaadin.flow.data.binder.ValueContext;
import com.vaadin.flow.data.converter.Converter;

public class StringToIntConverter implements Converter {

    @Override
    public Result convertToModel(String string, ValueContext valueContext) {
        try {
            return Result.ok(Integer.parseInt(string));
        } catch (Exception e) {
            return Result.error("请输入整数");
        }
    }

    @Override
    public String convertToPresentation(Integer integer, ValueContext valueContext) {
        return String.valueOf(integer);
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy