@Override public boolean remove(Recipe recipe) { if (allRecipes.get(recipe.getIngredients().size()) == null) { return false; } boolean failed = false; if (recipe instanceof ShapedRecipe) { failed = !removeShaped((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { failed = !removeShapeless((ShapelessRecipe) recipe); } failed = !allRecipes.get(recipe.getIngredients().size()).remove(recipe) || failed; return !failed; }
@Override public boolean register(Recipe recipe) { boolean failed = false; if (recipe instanceof ShapedRecipe) { failed = !registerShaped((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { failed = !registerShapeless((ShapelessRecipe) recipe); } else if (recipe instanceof SmeltedRecipe) { failed = !registerSmelted((SmeltedRecipe) recipe); } else { Spout.log("Unknown recipe type!"); } if (allRecipes.get(recipe.getIngredients().size()) == null) { allRecipes.put( recipe.getIngredients().size(), Collections.newSetFromMap(new ConcurrentHashMap<Recipe, Boolean>())); } failed = !allRecipes.get(recipe.getIngredients().size()).add(recipe) || failed; return !failed; }
public ServerRecipe(Recipe recipe) { this.author = recipe.getAuthor(); this.title = recipe.getTitle(); this.instructions = recipe.getInstructions(); this.ingredients = recipe.getIngredients(); this.uri = recipe.getUri(); ArrayList<Photo> photos = recipe.getPhotos(); this.photos = new ArrayList<ServerPhoto>(); ServerPhoto temp; for (Photo p : photos) { temp = new ServerPhoto(p); this.photos.add(temp); } }
public void addRecipeToDatabase(Recipe recipe) { connection.insertRecipe(recipe.getName(), recipe.getMethod(), recipe.getIngredients()); }