package com.ecep.contract.converter;

import com.ecep.contract.service.BankService;
import com.ecep.contract.vo.BankVo;
import javafx.util.StringConverter;

public class BankStringConverter extends StringConverter<BankVo> {

    BankService service;

    public BankStringConverter(BankService service) {
        this.service = service;
    }

    @Override
    public String toString(BankVo object) {
        return object == null ? "" : object.getCode() + " " + object.getName();
    }

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