Source:
public static IngredientsWithTagDialogFragment newInstance(Product product, AnalysisTagConfig config) { IngredientsWithTagDialogFragment frag = new IngredientsWithTagDialogFragment(); Bundle args = new Bundle(); args.putString("tag", config.getAnalysisTag()); args.putString("type", config.getType()); args.putString("type_name", config.getTypeName()); args.putString("icon_url", config.getIconUrl()); args.putString("color", config.getColor()); args.putString("name", config.getName().getName()); args.putString("ingredients_image_url", product.getImageIngredientsUrl()); if (product.getIngredients() == null || product.getIngredients().isEmpty()) { final List<String> statesTags = product.getStatesTags(); boolean ingredientsToBeCompleted = false; boolean photosToBeValidated = false; for (String stateTag : statesTags) { if (stateTag.equals("en:ingredients-to-be-completed")) { ingredientsToBeCompleted = true; } else if (stateTag.equals("en:photos-to-be-validated")) { photosToBeValidated = true; } } if (ingredientsToBeCompleted && photosToBeValidated) { args.putBoolean("photos_to_be_validated", true); } else { args.putBoolean("missing_ingredients", true); } } else { String showIngredients = config.getName().getShowIngredients(); if (showIngredients != null) { args.putSerializable("ingredients", getMatchingIngredientsText(product, showIngredients.split(":"))); } Optional<LinkedHashMap<String, String>> ambiguousIngredient = product.getIngredients().stream() .filter(ingredientList -> ingredientList.containsKey(config.getType()) && ingredientList.containsValue("maybe")).findFirst(); if (ambiguousIngredient.isPresent() && ambiguousIngredient.get().containsKey("text")) { args.putString(AMBIGUOUS_INGREDIENT_KEY, ambiguousIngredient.get().get("text")); } } frag.setArguments(args); return frag; }

Target:
public static IngredientsWithTagDialogFragment newInstance(Product product, AnalysisTagConfig config) { IngredientsWithTagDialogFragment frag = new IngredientsWithTagDialogFragment(); Bundle args = new Bundle(); args.putString("tag", config.getAnalysisTag()); args.putString("type", config.getType()); args.putString("type_name", config.getTypeName()); args.putString("icon_url", config.getIconUrl()); args.putString("color", config.getColor()); args.putString("name", config.getName().getName()); args.putString("ingredients_image_url", product.getImageIngredientsUrl()); if (product.getIngredients() == null || product.getIngredients().isEmpty()) { final List<String> statesTags = product.getStatesTags(); boolean ingredientsToBeCompleted = false; boolean photosToBeValidated = false; for (String stateTag : statesTags) { if (stateTag.equals("en:ingredients-to-be-completed")) { ingredientsToBeCompleted = true; } else if (stateTag.equals("en:photos-to-be-validated")) { photosToBeValidated = true; } } if (ingredientsToBeCompleted && photosToBeValidated) { args.putBoolean("photos_to_be_validated", true); } else { args.putBoolean("missing_ingredients", true); } } else { String showIngredients = config.getName().getShowIngredients(); if (showIngredients != null) { args.putSerializable("ingredients", getMatchingIngredientsText(product, showIngredients.split(":"))); } List<String> ambiguousIngredient = product.getIngredients().stream() .filter(ingredientList -> ingredientList.containsKey(config.getType()) && ingredientList.containsValue("maybe")) .filter(ingredient -> ingredient.containsKey("text")).map(ingredient -> ingredient.get("text")) .collect(Collectors.toList()); if (!ambiguousIngredient.isEmpty()) { args.putString(AMBIGUOUS_INGREDIENT_KEY, StringUtils.join(ambiguousIngredient, ",")); } } frag.setArguments(args); return frag; }