package com.ecep.contract.converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import com.ecep.contract.model.Company;
import com.ecep.contract.service.CompanyService;

import jakarta.annotation.PostConstruct;

@Lazy
@Component
public class CompanyStringConverter extends EntityStringConverter<Company> {

    @Lazy
    @Autowired
    CompanyService service;
    public CompanyStringConverter() {

    }

    @PostConstruct
    private void init() {
        setInitialized(project -> service.findById(project.getId()));
        setSuggestion(service::search);
        setFromString(service::findByName);
    }
}