tech.jhipster.lite.module.infrastructure.secondary.javadependency.JHipsterJavaDependenciesRepository Maven / Gradle / Ivy
package tech.jhipster.lite.module.infrastructure.secondary.javadependency;
import java.util.Collection;
import java.util.function.Function;
import org.springframework.stereotype.Repository;
import tech.jhipster.lite.module.domain.javadependency.ProjectJavaDependencies;
import tech.jhipster.lite.module.domain.javadependency.ProjectJavaDependenciesRepository;
import tech.jhipster.lite.module.domain.properties.JHipsterProjectFolder;
@Repository
class JHipsterJavaDependenciesRepository implements ProjectJavaDependenciesRepository {
private final Function javaDependencies;
public JHipsterJavaDependenciesRepository(Collection readers) {
javaDependencies = readJavaDependencies(readers);
}
private Function readJavaDependencies(
Collection readers
) {
return folder ->
readers.stream().map(reader -> reader.get(folder)).reduce(ProjectJavaDependencies.EMPTY, ProjectJavaDependencies::merge);
}
@Override
public ProjectJavaDependencies get(JHipsterProjectFolder folder) {
return javaDependencies.apply(folder);
}
}