Class Item

java.lang.Object
no.ntnu.idatt1002.demo.data.Item
All Implemented Interfaces:
Storable
Direct Known Subclasses:
ShoppingListItem

public class Item extends Object implements Storable
This class is a simple bean for an item.
  • Field Details

    • itemId

      private int itemId
    • name

      private final String name
    • category

      private final String category
    • allergy

      private final String allergy
  • Constructor Details

    • Item

      public Item(String name, String category, String allergy)
      Constructor for the Item class. When creating a new item, the id is not known.
      Parameters:
      name - the name of the item
      category - the category of the item
      allergy - the allergy of the item
    • Item

      public Item(int itemId, String name, String category, String allergy)
      Constructor for the Item class. When creating an item from the database, the id is known.
      Parameters:
      itemId - the id of the item
      name - the name of the item
      category - the category of the item
      allergy - the allergy of the item
  • Method Details

    • getAttributes

      public List<String> getAttributes()
      Returns the attributes of the item.
      Specified by:
      getAttributes in interface Storable
      Returns:
      the attribute names of the item
    • getAttributeNames

      public List<String> getAttributeNames()
      Returns the attribute names of the item.
      Specified by:
      getAttributeNames in interface Storable
      Returns:
      the attribute names of the item
    • getId

      public int getId()
      Returns the id of the item.
      Specified by:
      getId in interface Storable
      Returns:
      the id of the item
    • getIdName

      public String getIdName()
      Returns the name of the id.
      Specified by:
      getIdName in interface Storable
      Returns:
      the name of the id
    • getItemId

      public int getItemId()
      Returns the id of the item.
      Returns:
      the id of the item
    • getName

      public String getName()
      Returns the name of the item.
      Returns:
      the name of the item
    • getCategory

      public String getCategory()
      Returns the category of the item.
      Returns:
      the category of the item
    • getAllergy

      public String getAllergy()
      Returns the allergy of the item.
      Returns:
      the allergy of the item
    • toString

      public String toString()
      Returns a string representation of the item.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the item