All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.stapi.graphsystem.fixtures.fixtureCommandsGenerator.GenericFixtureCommandsGenerator Maven / Gradle / Ivy

package ai.stapi.graphsystem.fixtures.fixtureCommandsGenerator;

import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

public class GenericFixtureCommandsGenerator {

  private final List fixtureCommandsGenerators;

  @Autowired
  public GenericFixtureCommandsGenerator(List fixtureCommandsGenerators) {
    this.fixtureCommandsGenerators = fixtureCommandsGenerators;
  }

  public Stream generate(
      List tags,
      List processedGenerators,
      Set processedFileNames,
      float minPriority,
      float maxPriority
  ) {
    var fixtureCommandResults = this.fixtureCommandsGenerators.stream()
        .filter(fixtureCommandsGenerator ->
            fixtureCommandsGenerator.getPriority() >= minPriority
                && fixtureCommandsGenerator.getPriority() <= maxPriority
        )
        .sorted(Comparator.comparingDouble(FixtureCommandsGenerator::getPriority).reversed())
        .filter((generator) -> generator.getFixtureTags().stream().anyMatch(tags::contains)
            && !processedGenerators.contains(generator.getGeneratorName()))
        .map(fixtureCommandsGenerator -> fixtureCommandsGenerator.generate(processedFileNames))
        .toList();
    return fixtureCommandResults.stream();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy