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 ingredientprivate java.lang.Integer
ingredientID
ID of the ingredientprivate boolean
isVegan
Boolean if the ingredient is veganprivate boolean
isVegetarian
Boolean if the ingredient is vegetarianprivate java.lang.String
name
Name of the ingredientprivate java.lang.Integer
quantity
Quantity of the ingredientprivate 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 databaseIngredient(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 objectjava.lang.Integer
getIngredientID()
Gets the ID of the ingredientjava.lang.String
getName()
Gets the ingredient namejava.lang.Integer
getQuantity()
Gets the quantity of the ingredientIngredientUnit
getUnit()
Gets the unit for the ingredientboolean
isVegan()
Gets the boolean if the ingredient is veganboolean
isVegetarian()
Gets the boolean if the ingredient is vegetarianvoid
setIngredientCategory(IngredientCategory category)
Sets the category objectvoid
setName(java.lang.String name)
Sets the name of the ingredientvoid
setVegan(boolean vegan)
Defines if the ingredient is veganvoid
setVegetarian(boolean vegetarian)
Defines if the ingredient is vegetarianjava.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 ingredientIDID of the ingredient -
name
private java.lang.String nameName of the ingredient -
isVegan
private boolean isVeganBoolean if the ingredient is vegan -
isVegetarian
private boolean isVegetarianBoolean if the ingredient is vegetarian -
quantity
private java.lang.Integer quantityQuantity of the ingredient -
category
Category of the ingredient -
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 nameisVegan
- Is the ingredient veganisVegetarian
- Is the ingredient vegetariancategory
- 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 ingredientname
- Ingredient nameisVegan
- Is the ingredient veganisVegetarian
- Is the ingredient vegetariancategory
- Category object for the ingredient
-
Ingredient
public Ingredient(int ingredientID, int quantity, IngredientUnit unit) throws IngredientNotFoundExceptionConstructs an ingredient from its ID in the database- Parameters:
ingredientID
- IngredientIDquantity
- Quantity for the ingredientunit
- 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 classjava.lang.Object
- Returns:
- Name of the ingredient
-
getIngredientCategory
Gets the category object- Returns:
- IngredientCategory Object
-
setIngredientCategory
Sets the category object- Parameters:
category
- IngredientCategory Object
-
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)
-