Class ItemPrice


  • public class ItemPrice
    extends java.lang.Object
    Represents 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 ItemPrice class leverages Lombok's {@literal @}Data and {@literal @}Builder annotations, 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
      int getAverage()
      Calculates the average price for the item based on its high and low prices.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ItemPrice

        public ItemPrice()
    • 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 low and high prices. The formula used is low + ((high - low) / 2), which avoids potential floating-point arithmetic and maintains integer precision.

        Returns:
        The average price for the item as an integer value.