package com.ecep.contract.converter;

import com.ecep.contract.model.Project;
import com.ecep.contract.service.ProjectService;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Lazy
@Component
public class ProjectStringConverter extends EntityStringConverter<Project> {

    @Lazy
    @Autowired
    private ProjectService service;


    public ProjectStringConverter() {
    }

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


}
