package com.ecep.contract.converter;

import com.ecep.contract.Desktop;
import com.ecep.contract.service.CompanyFileTypeService;
import com.ecep.contract.vo.CompanyFileTypeLocalVo;
import javafx.util.StringConverter;

public class CompanyFileTypeStringConverter extends StringConverter<CompanyFileTypeLocalVo> {
    private final CompanyFileTypeService service;

    public CompanyFileTypeStringConverter(CompanyFileTypeService service) {
        this.service = service;
    }

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

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