Skip to content

Commit

Permalink
Remove DeclarativeRecipe specificity
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 20, 2024
1 parent 587fe42 commit be3e43b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ public final List<Recipe> getRecipeList() {
getName() + " declares the ScanningRecipe " + precondition.getName() + " as a precondition." +
"ScanningRecipe cannot be used as Preconditions.");
}
andPreconditions.add(precondition instanceof DeclarativeRecipe ?
(() -> or((DeclarativeRecipe) precondition)) : precondition::getVisitor);
andPreconditions.add(() -> orVisitors(precondition));
}
PreconditionBellwether bellwether = new PreconditionBellwether(Preconditions.and(andPreconditions.toArray(new Supplier[]{})));
List<Recipe> recipeListWithBellwether = new ArrayList<>(recipeList.size() + 1);
Expand All @@ -280,10 +279,11 @@ public final List<Recipe> getRecipeList() {
return recipeListWithBellwether;
}

private static TreeVisitor<?, ExecutionContext> or(DeclarativeRecipe recipe) {
private static TreeVisitor<?, ExecutionContext> orVisitors(Recipe recipe) {
List<TreeVisitor<?, ExecutionContext>> conditions = new ArrayList<>();
conditions.add(recipe.getVisitor());
for (Recipe r : recipe.getRecipeList()) {
conditions.add(r instanceof DeclarativeRecipe ? or((DeclarativeRecipe) r) : r.getVisitor());
conditions.add(orVisitors(r));
}
//noinspection unchecked
return Preconditions.or(conditions.toArray(new TreeVisitor[0]));
Expand Down

0 comments on commit be3e43b

Please sign in to comment.