package com.ecep.contract.converter;

import com.ecep.contract.Desktop;
import com.ecep.contract.service.VendorFileTypeService;
import com.ecep.contract.vo.VendorFileTypeLocalVo;
import javafx.util.StringConverter;

public class VendorFileTypeStringConverter extends StringConverter<VendorFileTypeLocalVo> {
    private final VendorFileTypeService service;

    public VendorFileTypeStringConverter(VendorFileTypeService service) {
        this.service = service;
    }

    @Override
    public String toString(VendorFileTypeLocalVo object) {
        return object.getValue();
    }

    @Override
    public VendorFileTypeLocalVo fromString(String string) {
        return service.findByLocaleAndValue(Desktop.instance.getActiveEmployee().localeProperty().get(), string);
    }
}