tech.jhipster.lite.module.infrastructure.secondary.javadependency.JHipsterJavaDependenciesVersionsRepository Maven / Gradle / Ivy
package tech.jhipster.lite.module.infrastructure.secondary.javadependency;
import java.util.Collection;
import java.util.function.Supplier;
import org.springframework.stereotype.Repository;
import tech.jhipster.lite.module.domain.javadependency.JavaDependenciesVersions;
import tech.jhipster.lite.module.domain.javadependency.JavaDependenciesVersionsRepository;
import tech.jhipster.lite.shared.memoizer.domain.Memoizers;
@Repository
class JHipsterJavaDependenciesVersionsRepository implements JavaDependenciesVersionsRepository {
private final Supplier versions;
public JHipsterJavaDependenciesVersionsRepository(Collection readers) {
versions = Memoizers.of(readVersions(readers));
}
private Supplier readVersions(Collection readers) {
return () -> readers.stream().map(JavaDependenciesReader::get).reduce(JavaDependenciesVersions.EMPTY, JavaDependenciesVersions::merge);
}
@Override
public JavaDependenciesVersions get() {
return versions.get();
}
}