Class Ingredient

java.lang.Object
de.hebkstudents.recipemanager.ingredient.Ingredient

public class Ingredient
extends java.lang.Object
Class to generate ingredient objects for recipes and other
  • Field Summary

    Fields
    Modifier and Type Field Description
    private IngredientCategory category
    Category of the ingredient
    private java.lang.Integer ingredientID
    ID of the ingredient
    private boolean isVegan
    Boolean if the ingredient is vegan
    private boolean isVegetarian
    Boolean if the ingredient is vegetarian
    private java.lang.String name
    Name of the ingredient
    private java.lang.Integer quantity
    Quantity of the ingredient
    private IngredientUnit unit
    Unit of the ingredient
  • Constructor Summary

    Constructors
    Constructor Description
    Ingredient​(int ingredientID, int quantity, IngredientUnit unit)
    Constructs an ingredient from its ID in the database
    Ingredient​(int ingredientID, java.lang.String name, boolean isVegan, boolean isVegetarian, IngredientCategory category)
    Ingredient constructor.
    Ingredient​(java.lang.String name, boolean isVegan, boolean isVegetarian, IngredientCategory category)
    Ingredient cunstructor.
  • Method Summary

    Modifier and Type Method Description
    IngredientCategory getIngredientCategory()
    Gets the category object
    java.lang.Integer getIngredientID()
    Gets the ID of the ingredient
    java.lang.String getName()
    Gets the ingredient name
    java.lang.Integer getQuantity()
    Gets the quantity of the ingredient
    IngredientUnit getUnit()
    Gets the unit for the ingredient
    boolean isVegan()
    Gets the boolean if the ingredient is vegan
    boolean isVegetarian()
    Gets the boolean if the ingredient is vegetarian
    void setIngredientCategory​(IngredientCategory category)
    Sets the category object
    void setName​(java.lang.String name)
    Sets the name of the ingredient
    void setVegan​(boolean vegan)
    Defines if the ingredient is vegan
    void setVegetarian​(boolean vegetarian)
    Defines if the ingredient is vegetarian
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ingredientID

      private java.lang.Integer ingredientID
      ID of the ingredient
    • name

      private java.lang.String name
      Name of the ingredient
    • isVegan

      private boolean isVegan
      Boolean if the ingredient is vegan
    • isVegetarian

      private boolean isVegetarian
      Boolean if the ingredient is vegetarian
    • quantity

      private java.lang.Integer quantity
      Quantity of the ingredient
    • category

      private IngredientCategory category
      Category of the ingredient
    • unit

      private IngredientUnit unit
      Unit of the ingredient
  • Constructor Details

    • Ingredient

      public Ingredient​(java.lang.String name, boolean isVegan, boolean isVegetarian, IngredientCategory category)
      Ingredient cunstructor.
      Parameters:
      name - Ingredient name
      isVegan - Is the ingredient vegan
      isVegetarian - Is the ingredient vegetarian
      category - Category object for the ingredient
    • Ingredient

      public Ingredient​(int ingredientID, java.lang.String name, boolean isVegan, boolean isVegetarian, IngredientCategory category)
      Ingredient constructor.
      Parameters:
      ingredientID - ID of the ingredient
      name - Ingredient name
      isVegan - Is the ingredient vegan
      isVegetarian - Is the ingredient vegetarian
      category - Category object for the ingredient
    • Ingredient

      public Ingredient​(int ingredientID, int quantity, IngredientUnit unit) throws IngredientNotFoundException
      Constructs an ingredient from its ID in the database
      Parameters:
      ingredientID - IngredientID
      quantity - Quantity for the ingredient
      unit - Unit for the ingredient
      Throws:
      IngredientNotFoundException - If an ingredient is requested that does not exist!
  • Method Details

    • getIngredientID

      public java.lang.Integer getIngredientID()
      Gets the ID of the ingredient
      Returns:
      ID
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
      Returns:
      Name of the ingredient
    • getIngredientCategory

      public IngredientCategory getIngredientCategory()
      Gets the category object
      Returns:
      IngredientCategory Object
    • setIngredientCategory

      public void setIngredientCategory​(IngredientCategory category)
      Sets the category object
      Parameters:
      category - IngredientCategory Object
    • getUnit

      public IngredientUnit getUnit()
      Gets the unit for the ingredient
      Returns:
      unit object
    • getName

      public java.lang.String getName()
      Gets the ingredient name
      Returns:
      ingredeint name
    • setName

      public void setName​(java.lang.String name)
      Sets the name of the ingredient
      Parameters:
      name - name of the ingredient
    • isVegan

      public boolean isVegan()
      Gets the boolean if the ingredient is vegan
      Returns:
      true if its vegan
    • setVegan

      public void setVegan​(boolean vegan)
      Defines if the ingredient is vegan
      Parameters:
      vegan - true if it is vegan
    • isVegetarian

      public boolean isVegetarian()
      Gets the boolean if the ingredient is vegetarian
      Returns:
      true if its vegetarian
    • setVegetarian

      public void setVegetarian​(boolean vegetarian)
      Defines if the ingredient is vegetarian
      Parameters:
      vegetarian - true if it is vegetarian
    • getQuantity

      public java.lang.Integer getQuantity()
      Gets the quantity of the ingredient
      Returns:
      Quantity (null -> not set)