content: package io.reflectoring.coderadar.projectadministration.service.module;
  
  import io.reflectoring.coderadar.domain.Module;
  import io.reflectoring.coderadar.projectadministration.ProjectNotFoundException;
  import io.reflectoring.coderadar.projectadministration.port.driven.module.ListModulesOfProjectPort;
  import io.reflectoring.coderadar.projectadministration.port.driven.project.GetProjectPort;
  import io.reflectoring.coderadar.projectadministration.port.driver.module.get.ListModulesOfProjectUseCase;
  import java.util.List;
  import lombok.RequiredArgsConstructor;
  import org.springframework.stereotype.Service;
  
  @Service
  @RequiredArgsConstructor
  public class ListModulesOfProjectService implements ListModulesOfProjectUseCase {
  
    private final ListModulesOfProjectPort port;
    private final GetProjectPort getProjectPort;
  
    @Override
    public List<Module> listModules(long projectId) {
      if (getProjectPort.existsById(projectId)) {
        return port.listModules(projectId);
      } else {
        throw new ProjectNotFoundException(projectId);
      }
    }
  }
  