package com.ecep.contract.converter;

import com.ecep.contract.Desktop;
import com.ecep.contract.service.ContractFileTypeService;
import com.ecep.contract.vo.ContractFileTypeLocalVo;
import javafx.util.StringConverter;

public class ContractFileTypeStringConverter extends StringConverter<ContractFileTypeLocalVo> {
    private final ContractFileTypeService service;

    public ContractFileTypeStringConverter(ContractFileTypeService service) {
        this.service = service;
    }

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

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