package pl.sudra.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import pl.sudra.domain.Address;
import pl.sudra.service.AddressService;

public class AddressConverter implements Converter<String, Address> {

    private AddressService addressService;

//    @Autowired
    public AddressConverter(AddressService addressService) {
        this.addressService = addressService;
    }

    @Override
    public Address convert(String source) {
        return addressService.getAddress(Integer.parseInt(source));
    }
}
