Record Class ModernMaterialStore.ModernInventoryStats
java.lang.Object
java.lang.Record
com.university.bookstore.api.ModernMaterialStore.ModernInventoryStats
- Record Components:
totalCount- total number of materialsaveragePrice- average price of all materialsmedianPrice- median price of all materialsuniqueTypes- number of unique material typesmediaCount- number of media materialsprintCount- number of printed materials
- Enclosing interface:
ModernMaterialStore
public static record ModernMaterialStore.ModernInventoryStats(int totalCount, double averagePrice, double medianPrice, int uniqueTypes, int mediaCount, int printCount)
extends Record
Modern InventoryStats using Java record for immutability.
Records provide built-in equals(), hashCode(), and toString() methods.
- Since:
- 2024-09-15
- Version:
- 4.0
- Author:
- Navid Mohaghegh
-
Constructor Summary
ConstructorsConstructorDescriptionModernInventoryStats(int totalCount, double averagePrice, double medianPrice, int uniqueTypes, int mediaCount, int printCount) Compact constructor for validation. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of theaveragePricerecord component.empty()Creates an empty stats instance.final booleanIndicates whether some other object is "equal to" this one.doubleGets the percentage of media materials.doubleGets the percentage of print materials.Creates a summary string for reporting.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Checks if the inventory is empty.intReturns the value of themediaCountrecord component.doubleReturns the value of themedianPricerecord component.intReturns the value of theprintCountrecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thetotalCountrecord component.intReturns the value of theuniqueTypesrecord component.
-
Constructor Details
-
ModernInventoryStats
public ModernInventoryStats(int totalCount, double averagePrice, double medianPrice, int uniqueTypes, int mediaCount, int printCount) Compact constructor for validation.
-
-
Method Details
-
empty
Creates an empty stats instance.- Returns:
- stats with all zero values
-
isEmpty
public boolean isEmpty()Checks if the inventory is empty.- Returns:
- true if total count is zero
-
getMediaPercentage
public double getMediaPercentage()Gets the percentage of media materials.- Returns:
- media percentage (0-100)
-
getPrintPercentage
public double getPrintPercentage()Gets the percentage of print materials.- Returns:
- print percentage (0-100)
-
getSummary
-
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. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
totalCount
public int totalCount()Returns the value of thetotalCountrecord component.- Returns:
- the value of the
totalCountrecord component
-
averagePrice
public double averagePrice()Returns the value of theaveragePricerecord component.- Returns:
- the value of the
averagePricerecord component
-
medianPrice
public double medianPrice()Returns the value of themedianPricerecord component.- Returns:
- the value of the
medianPricerecord component
-
uniqueTypes
public int uniqueTypes()Returns the value of theuniqueTypesrecord component.- Returns:
- the value of the
uniqueTypesrecord component
-
mediaCount
public int mediaCount()Returns the value of themediaCountrecord component.- Returns:
- the value of the
mediaCountrecord component
-
printCount
public int printCount()Returns the value of theprintCountrecord component.- Returns:
- the value of the
printCountrecord component
-