Class ItemPrice
- java.lang.Object
-
- com.kraken.api.service.util.price.ItemPrice
-
public class ItemPrice extends java.lang.ObjectRepresents price data for an item in Old School RuneScape (OSRS), including high and low prices along with their respective timestamps.This class is typically used as a data model for interfacing with price-related APIs or services operating within the OSRS ecosystem.
Attributes:
- itemId: The unique identifier for the item.
- high: The highest price recorded for the item.
- low: The lowest price recorded for the item.
- highTimestamp: The timestamp (as a Unix epoch) when the high price was last recorded.
- lowTimestamp: The timestamp (as a Unix epoch) when the low price was last recorded.
The
ItemPriceclass leverages Lombok's{@literal @}Dataand{@literal @}Builderannotations, which provide boilerplate code generation for getters, setters, builder pattern, and more.This object is immutable when using the builder pattern, ensuring consistent and thread-safe data access across concurrent operations.
-
-
Constructor Summary
Constructors Constructor Description ItemPrice()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAverage()Calculates the average price for the item based on its high and low prices.
-
-
-
Method Detail
-
getAverage
public int getAverage()
Calculates the average price for the item based on its high and low prices.The average is determined by finding the midpoint between the
lowandhighprices. The formula used islow + ((high - low) / 2), which avoids potential floating-point arithmetic and maintains integer precision.- Returns:
- The average price for the item as an integer value.
-
-