package ch.epfl.maze.physical.stragegies.reducer; import ch.epfl.maze.physical.World; import ch.epfl.maze.util.Direction; import java.util.Set; import java.util.stream.Collectors; /** * A filter reducer filtering possibilities case by case. * * @author Pacien TRAN-GIRARD */ public interface CaseReducer extends ChoiceReducer { /** * Checks if the given choice should be kept or excluded by the filter. * * @param choice A Direction * @param world The World * @return T(The filter should keep the given choice) */ boolean keepChoice(Direction choice, World world); @Override default Set reduce(Set choices, World world) { return choices .stream() .filter(choice -> this.keepChoice(choice, world)) .collect(Collectors.toSet()); } }