<commit_before>package mezz.jei.recipes;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import mezz.jei.api.gui.IRecipeLayoutDrawable;
import mezz.jei.api.helpers.IModIdHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IRecipeManager;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.gui.Focus;
import mezz.jei.gui.recipes.RecipeLayout;
import mezz.jei.util.ErrorUtil;
import net.minecraft.resources.ResourceLocation;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;

public class RecipeManager implements IRecipeManager {
	private final RecipeManagerInternal internal;
	private final IModIdHelper modIdHelper;

	public RecipeManager(RecipeManagerInternal internal, IModIdHelper modIdHelper) {
		this.internal = internal;
		this.modIdHelper = modIdHelper;
	}

	@Override
	public <V> IFocus<V> createFocus(IFocus.Mode mode, V ingredient) {
		return new Focus<>(mode, ingredient);
	}

	@Override
	@Deprecated
	public <T> void addRecipe(T recipe, ResourceLocation recipeCategoryUid) {
		ErrorUtil.checkNotNull(recipe, "recipe");
		ErrorUtil.checkNotNull(recipeCategoryUid, "recipeCategoryUid");
		ErrorUtil.assertMainThread();

		internal.addRecipe(recipe, recipeCategoryUid);
	}

	@Override
	@Nullable
	public IRecipeCategory<?> getRecipeCategory(ResourceLocation recipeCategoryUid, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategoryUid, "recipeCategoryUid");
		return internal.getRecipeCategoriesStream(ImmutableSet.of(recipeCategoryUid), null, includeHidden)
			.findFirst()
			.orElse(null);
	}

	@Override
	public <V> ImmutableList<IRecipeCategory<?>> getRecipeCategories(Collection<ResourceLocation> recipeCategoryUids, @Nullable IFocus<V> focus, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategoryUids, "recipeCategoryUids");
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipeCategoriesStream(recipeCategoryUids, internalFocus, includeHidden)
			.collect(ImmutableList.toImmutableList());
	}

	@Override
	public <V> ImmutableList<IRecipeCategory<?>> getRecipeCategories(@Nullable IFocus<V> focus, boolean includeHidden) {
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipeCategoriesStream(null, internalFocus, includeHidden)
			.collect(ImmutableList.toImmutableList());
	}

	@Override
	public <T, V> ImmutableList<T> getRecipes(IRecipeCategory<T> recipeCategory, @Nullable IFocus<V> focus, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategory, "recipeCategory");
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipesStream(recipeCategory, internalFocus, includeHidden)
			.collect(ImmutableList.toImmutableList());
	}

	@Override
	public List<Object> getRecipeCatalysts(IRecipeCategory<?> recipeCategory, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategory, "recipeCategory");
		return internal.getRecipeCatalysts(recipeCategory, includeHidden);
	}<commit_msg>Fix #2468 Return a mutable list from RecipeManager methods for easier consumption<commit_after>package mezz.jei.recipes;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import mezz.jei.api.gui.IRecipeLayoutDrawable;
import mezz.jei.api.helpers.IModIdHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IRecipeManager;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.gui.Focus;
import mezz.jei.gui.recipes.RecipeLayout;
import mezz.jei.util.ErrorUtil;
import net.minecraft.resources.ResourceLocation;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class RecipeManager implements IRecipeManager {
	private final RecipeManagerInternal internal;
	private final IModIdHelper modIdHelper;

	public RecipeManager(RecipeManagerInternal internal, IModIdHelper modIdHelper) {
		this.internal = internal;
		this.modIdHelper = modIdHelper;
	}

	@Override
	public <V> IFocus<V> createFocus(IFocus.Mode mode, V ingredient) {
		return new Focus<>(mode, ingredient);
	}

	@Override
	@Deprecated
	public <T> void addRecipe(T recipe, ResourceLocation recipeCategoryUid) {
		ErrorUtil.checkNotNull(recipe, "recipe");
		ErrorUtil.checkNotNull(recipeCategoryUid, "recipeCategoryUid");
		ErrorUtil.assertMainThread();

		internal.addRecipe(recipe, recipeCategoryUid);
	}

	@Override
	@Nullable
	public IRecipeCategory<?> getRecipeCategory(ResourceLocation recipeCategoryUid, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategoryUid, "recipeCategoryUid");
		return internal.getRecipeCategoriesStream(ImmutableSet.of(recipeCategoryUid), null, includeHidden)
			.findFirst()
			.orElse(null);
	}

	@Override
	public <V> List<IRecipeCategory<?>> getRecipeCategories(Collection<ResourceLocation> recipeCategoryUids, @Nullable IFocus<V> focus, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategoryUids, "recipeCategoryUids");
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipeCategoriesStream(recipeCategoryUids, internalFocus, includeHidden)
			.collect(Collectors.toList());
	}

	@Override
	public <V> List<IRecipeCategory<?>> getRecipeCategories(@Nullable IFocus<V> focus, boolean includeHidden) {
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipeCategoriesStream(null, internalFocus, includeHidden)
			.collect(Collectors.toList());
	}

	@Override
	public <T, V> List<T> getRecipes(IRecipeCategory<T> recipeCategory, @Nullable IFocus<V> focus, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategory, "recipeCategory");
		Focus<V> internalFocus = Focus.checkNullable(focus);
		return internal.getRecipesStream(recipeCategory, internalFocus, includeHidden)
			.collect(Collectors.toList());
	}

	@Override
	public List<Object> getRecipeCatalysts(IRecipeCategory<?> recipeCategory, boolean includeHidden) {
		ErrorUtil.checkNotNull(recipeCategory, "recipeCategory");
		return internal.getRecipeCatalysts(recipeCategory, includeHidden);
	}
{'fraction_non_alphanumeric': 0.10196460464361097, 'fraction_numerical': 0.000649456080532554, 'mean_word_length': 7.3130904183535765, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3625409', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1895, 'n_words': 351}