Class Item
java.lang.Object
org.troy.capstone.entities.Item
- All Implemented Interfaces:
Cloneable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringCategory of the item.private DateDate the item was added to the collection.private StringDescription of the item.private static final FakerFaker instance for generating random data.private StringUnique identifier for the item.private StringURL of the item's image.private shortIndex of the item in the collection.private static final JaroWinklerSimilarityJaro-Winkler similarity instance for calculating string similarity.private StringName of the item.private StringAuthor of the item's photo.private StringURL of the photo's author.private floatPrice of the item.private StringPublisher of the item.private shortNumber of reviews for the item.private floatReview score of the item.private shortQuantity of the item in stock.Tags associated with the item. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateItem()Private constructor to prevent direct instantiation of the Item class and to satisfy a Javadoc warning. -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a deep copy of thisIteminstance.static ItemCreates anItemobject from a tablesawRow.getAttribute(TableColumnName column) Returns the value of the specified attribute for this item.static ItemDeprecated.Used for testing purposes, not intended for production use.floatsimilarity(Item other) Calculates a similarity score between this item and another item based on shared attributes such as category, publisher, tags, and price.
-
Field Details
-
faker
Faker instance for generating random data. -
id
Unique identifier for the item. -
index
private short indexIndex of the item in the collection. -
imageUrl
URL of the item's image. -
name
Name of the item. -
publisher
Publisher of the item. -
description
Description of the item. -
category
Category of the item. -
tags
-
photoAuthor
Author of the item's photo. -
photoAuthorUrl
URL of the photo's author. -
price
private float pricePrice of the item. -
reviewScore
private float reviewScoreReview score of the item. -
reviewCount
private short reviewCountNumber of reviews for the item. -
stockQuantity
private short stockQuantityQuantity of the item in stock. -
dateAdded
Date the item was added to the collection. -
JARO_WINKLER_SIMILARITY
Jaro-Winkler similarity instance for calculating string similarity.
-
-
Constructor Details
-
Item
private Item()Private constructor to prevent direct instantiation of the Item class and to satisfy a Javadoc warning.
-
-
Method Details
-
getAttribute
Returns the value of the specified attribute for this item. The attribute is determined by the providedTableColumnNameenum value.- Parameters:
column- An enum value representing the attribute to retrieve from this item.- Returns:
- The value of the specified attribute for this item, returned as an Object. The caller must cast result.
- Throws:
IllegalArgumentException- If the provided column does not correspond to a valid attribute of theItemclass.- Preconditions:
- column is not null and corresponds to a valid attribute of the
Itemclass.
-
randomItem
Deprecated.Used for testing purposes, not intended for production use.Generates a randomItemobject with realistic values for each attribute using theFakerlibrary.- Returns:
- A randomly generated
Itemobject with all attributes populated with realistic random values.
-
fromRow
Creates anItemobject from a tablesawRow. TheRowmust contain columns corresponding to the attributes of theItemclass. The method of converting aLocalDateto aDateis sourced from [7].- Parameters:
itemRow- ARowfrom a tablesawTablecontaining item info.- Returns:
- An
Itemobject created from the data in the providedRow. - Preconditions:
- itemRow is not null and contains the expected columns for creating an
Item(ID, Name, etc.).
-
similarity
Calculates a similarity score between this item and another item based on shared attributes such as category, publisher, tags, and price. The similarity score is a float value between 0.0 and 1.0, where higher values indicate greater similarity.- Parameters:
other- The other Item to compare against this item for similarity.- Returns:
- A float value representing the similarity between the two items.
-
clone
Creates and returns a deep copy of thisIteminstance.- Overrides:
clonein classObject- Returns:
- A deep copy of this
Iteminstance. - Throws:
CloneNotSupportedException- if theItemcannot be cloned.
-