package com.ecep.contract.converter;

import com.ecep.contract.service.VendorCatalogService;
import com.ecep.contract.vo.VendorCatalogVo;
import javafx.util.StringConverter;

public class VendorCatalogStringConverter extends StringConverter<VendorCatalogVo> {
    private final VendorCatalogService service;

    public VendorCatalogStringConverter(VendorCatalogService service) {
        this.service = service;
    }

    @Override
    public String toString(VendorCatalogVo object) {
        return object.getName();
    }

    @Override
    public VendorCatalogVo fromString(String string) {
        return service.findByName(string);
    }
}
