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 IngredientCategorycategoryCategory of the ingredientprivate java.lang.IntegeringredientIDID of the ingredientprivate booleanisVeganBoolean if the ingredient is veganprivate booleanisVegetarianBoolean if the ingredient is vegetarianprivate java.lang.StringnameName of the ingredientprivate java.lang.IntegerquantityQuantity of the ingredientprivate IngredientUnitunitUnit 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 IngredientCategorygetIngredientCategory()Gets the category objectjava.lang.IntegergetIngredientID()Gets the ID of the ingredientjava.lang.StringgetName()Gets the ingredient namejava.lang.IntegergetQuantity()Gets the quantity of the ingredientIngredientUnitgetUnit()Gets the unit for the ingredientbooleanisVegan()Gets the boolean if the ingredient is veganbooleanisVegetarian()Gets the boolean if the ingredient is vegetarianvoidsetIngredientCategory(IngredientCategory category)Sets the category objectvoidsetName(java.lang.String name)Sets the name of the ingredientvoidsetVegan(boolean vegan)Defines if the ingredient is veganvoidsetVegetarian(boolean vegetarian)Defines if the ingredient is vegetarianjava.lang.StringtoString()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:
toStringin 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)
-