// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.sps.data;

import java.util.List;
import java.util.Objects;

public final class Recipe {

  private final String name;
  private final String time;
  private final String calories;
  private final String difficulty;
  private final String imageUrl;
  private final List<String> dietaryRequirements;
  private final List<String> ingredients;
  private final List<String> instructions;
  private final int recipeId;

  public Recipe(
      String name,
      String time,
      String calories,
      String difficulty,
      String imageUrl,
      List<String> dietaryRequirements,
      List<String> ingredients,
      List<String> instructions) {
    this.name = name;
    this.time = time;
    this.calories = calories;
    this.difficulty = difficulty;
    this.imageUrl = imageUrl;
    this.dietaryRequirements = dietaryRequirements;
    this.ingredients = ingredients;
    this.instructions = instructions;
    this.recipeId = this.hashCode();
  }

  public boolean containsDietaryRequirement(String diet) {
    if (dietaryRequirements == null) {
      return false;
    }
    return dietaryRequirements.contains(diet);
  }

  public boolean containsIngredient(String ingredient) {
    for (String recipeIngredient : ingredients) {
      if (recipeIngredient.contains(ingredient)) {
        return true;
      }
    }
    return false;
  }

  public String getName() {
    return name;
  }

  public String getTime() {
    return time;
  }

  public String getCalories() {
    return calories;
  }

  public String getDifficulty() {
    return difficulty;
  }

  public String getImageUrl() {
    return imageUrl;
  }

  public List<String> getDietaryRequirements() {
    return dietaryRequirements;
  }

  public List<String> getIngredients() {
    return ingredients;
  }

  public List<String> getInstructions() {
    return instructions;
  }

  @Override
  public boolean equals(Object other) {
    if (this == other) return true;
    if (other == null || getClass() != other.getClass()) return false;
    Recipe recipe = (Recipe) other;
    return name.equals(recipe.name)
        && time.equals(recipe.time)
        && calories.equals(recipe.calories)
        && difficulty.equals(recipe.difficulty)
        && imageUrl.equals(recipe.imageUrl)
        && dietaryRequirements.equals(recipe.dietaryRequirements)
        && ingredients.equals(recipe.ingredients)
        && instructions.equals(recipe.instructions);
  }

  @Override
  public int hashCode() {
    int multiplier = 31;
    int result = Objects.hash(name, time, calories, difficulty, imageUrl);
    if (dietaryRequirements != null) {
      result = multiplier * result + dietaryRequirements.hashCode();
    }
    result = multiplier * result + ingredients.hashCode();
    result = multiplier * result + instructions.hashCode();
    return result;
  }

  @Override
  public String toString() {
    return "name: " + name + "\n"
        + "time: " + time + "\n" 
        + "calories: " + calories + "\n" 
        + "difficulty: " + difficulty + "\n"
        + "imageUrl: " + imageUrl + "\n"
        + "diet: " + dietaryRequirements + "\n" 
        + "ingredients: " + ingredients + "\n" 
        + "instructions: " + instructions;
  }
}

@@ -612,16 +612,72 @@
 .data;%0A%0A
+import com.google.common.annotations.VisibleForTesting;%0A
 import j
@@ -1995,32 +1995,53 @@
 urn false;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public String 
@@ -2048,24 +2048,24 @@
 getName() %7B%0A
-
     return n
@@ -2066,32 +2066,53 @@
 turn name;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public String 
@@ -2141,24 +2141,45 @@
  time;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public Str
@@ -2216,32 +2216,53 @@
  calories;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public String 
@@ -2303,24 +2303,45 @@
 culty;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public Str
@@ -2382,24 +2382,45 @@
 geUrl;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public Lis
@@ -2485,32 +2485,53 @@
 uirements;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public List%3CSt
@@ -2580,24 +2580,45 @@
 ients;%0A  %7D%0A%0A
+  @VisibleForTesting%0A
   public Lis

Add annotations for Recipe class getters