Package no.ntnu.idatt1002.demo.data
Class Item
java.lang.Object
no.ntnu.idatt1002.demo.data.Item
- All Implemented Interfaces:
Storable
- Direct Known Subclasses:
ShoppingListItem
This class is a simple bean for an item.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the allergy of the item.Returns the attribute names of the item.Returns the attributes of the item.Returns the category of the item.int
getId()
Returns the id of the item.Returns the name of the id.int
Returns the id of the item.getName()
Returns the name of the item.toString()
Returns a string representation of the item.
-
Field Details
-
itemId
private int itemId -
name
-
category
-
allergy
-
-
Constructor Details
-
Item
Constructor for the Item class. When creating a new item, the id is not known.- Parameters:
name
- the name of the itemcategory
- the category of the itemallergy
- the allergy of the item
-
Item
Constructor for the Item class. When creating an item from the database, the id is known.- Parameters:
itemId
- the id of the itemname
- the name of the itemcategory
- the category of the itemallergy
- the allergy of the item
-
-
Method Details
-
getAttributes
Returns the attributes of the item.- Specified by:
getAttributes
in interfaceStorable
- Returns:
- the attribute names of the item
-
getAttributeNames
Returns the attribute names of the item.- Specified by:
getAttributeNames
in interfaceStorable
- Returns:
- the attribute names of the item
-
getId
public int getId()Returns the id of the item. -
getIdName
Returns the name of the id. -
getItemId
public int getItemId()Returns the id of the item.- Returns:
- the id of the item
-
getName
Returns the name of the item.- Returns:
- the name of the item
-
getCategory
Returns the category of the item.- Returns:
- the category of the item
-
getAllergy
Returns the allergy of the item.- Returns:
- the allergy of the item
-
toString
Returns a string representation of the item.
-