package com.ecep.contract.converter;

import com.ecep.contract.Desktop;
import com.ecep.contract.service.ProjectFileTypeService;
import com.ecep.contract.vo.ProjectFileTypeLocalVo;

import javafx.util.StringConverter;

public class ProjectFileTypeStringConverter extends StringConverter<ProjectFileTypeLocalVo> {
    private final ProjectFileTypeService service;

    public ProjectFileTypeStringConverter(ProjectFileTypeService service) {
        this.service = service;
    }

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

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