Record Class ItemOrder
java.lang.Object
java.lang.Record
edu.uw.tcss.model.ItemOrder
- Record Components:
item- the Item being orderedquantity- the quantity of the item being ordered
Represents a purchase order for an item - an immutable pairing of an Item
with a desired quantity.
This is a pure data holder implemented as a Java record. It does not contain display logic or business logic - it simply holds the item and quantity. The GUI or other code is responsible for formatting this data for display.
Being a record, this class automatically provides: - Constructor with all fields - Accessor methods: item() and quantity() - equals() and hashCode() based on all fields - toString() in debug format: "ItemOrder[item=..., quantity=...]" - Immutability (all fields are final)
- Version:
- Winter 2026
- Author:
- Charles Bryan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.item()Returns the value of theitemrecord component.intquantity()Returns the value of thequantityrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ItemOrder
Compact constructor that validates the item and quantity.- Throws:
NullPointerException- if item is nullIllegalArgumentException- if quantity is negative
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
item
-
quantity
-