public class Ingredient extends Object
Recipe
s. Each Ingredient consists of a quantity
String, a unit
Ingredient.Unit
, and a name
String. Unit is primarily
an Enum
of abbreviated cooking terms, but also allows the value Ingredient.Unit.OTHER
with
unitAlt
as a String stand-in for less-common terms (i.e. sprig) and items measured whole
(i.e. eggs)Modifier and Type | Class and Description |
---|---|
static class |
Ingredient.Unit
This Enum holds values for units of measurement with an "OTHER" option to handle additional
values.
|
Constructor and Description |
---|
Ingredient() |
Ingredient(long recipeId,
String quantity,
Ingredient.Unit unit,
String unitAlt,
String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
long |
getId() |
String |
getName() |
String |
getQuantity() |
long |
getRecipeId() |
Ingredient.Unit |
getUnit() |
String |
getUnitAlt() |
String |
getUnitText() |
int |
hashCode() |
void |
setId(long id) |
void |
setName(String name) |
void |
setQuantity(String quantity) |
void |
setRecipeId(long recipeId) |
void |
setUnit(Ingredient.Unit unit) |
void |
setUnitAlt(String unitAlt) |
void |
setUnitText(String unit) |
String |
toString() |
public Ingredient()
public Ingredient(long recipeId, String quantity, Ingredient.Unit unit, String unitAlt, String name)
recipeId
- received from the parent Recipe
quantity
- is the amount of Ingredient.Unit
. Takes a String to avoid dealing with
fraction/decimal conversions and unicode characters like '⅔'.unit
- is the unit of measurement.unitAlt
- is optional; used if the unit parameter is Ingredient.Unit.OTHER
.name
- is the name of the ingredient.public long getId()
public void setId(long id)
id
- is generated when an Ingredient is inserted into the database.public long getRecipeId()
public void setRecipeId(long recipeId)
recipeId
- is received from the parent Recipe.public String getQuantity()
public void setQuantity(String quantity)
quantity
- is set by the user in the EditingFragment.public Ingredient.Unit getUnit()
public void setUnit(Ingredient.Unit unit)
unit
- is set by the user in the EditingFragment.public String getUnitText()
public void setUnitText(String unit)
unit
- is set by the user in the EditingFragment.public String getUnitAlt()
public void setUnitAlt(String unitAlt)
unitAlt
- is set by the user in the EditingFragment.public String getName()
public void setName(String name)
name
- is set by the user in the EditingFragment.public int hashCode()