Skip to content

Commit

Permalink
fix: stop throwing a null pointer if the repository item is null
Browse files Browse the repository at this point in the history
(cherry picked from commit ab331aa)
  • Loading branch information
Morazzer committed Nov 11, 2024
1 parent 64e59d7 commit f95e7bb
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static Result<RecipeCalculationResult, String> calculate(Recipe recipe, C
}

private static Optional<Recipe> getBestRecipe(RepositoryItem repositoryItem, boolean flip) {
if (repositoryItem == null) {
return Optional.empty();
}
return repositoryItem.getRecipes()
.stream().min(Comparator.comparingInt(recipe -> (flip ? -1 : 1) * recipe.getOutput().getAmount()));
}
Expand Down

0 comments on commit f95e7bb

Please sign in to comment.