Class ItemQuery

java.lang.Object
privbot.query.ItemQuery

public final class ItemQuery extends Object
Fluent filter chain over inventory-style slot rows wrapped as PrivItem.

Built by ctx.inventory.query(), ctx.bank and ctx.equipment. Rows are a snapshot of the container when the query was built. Filters narrow the query in place, so a query is single-use. Name filters resolve each item's name (marshalled per item); an item whose name cannot be resolved reads as "item:<id>" and matches no name, so an empty result is not proof the item is absent; filter by id when you have one.

  • Method Details

    • withName

      public ItemQuery withName(String... names)
      Keeps items whose name contains any of names (case-insensitive substring), so "Shark" also matches "Raw shark". See the class note on unresolved names.
    • withId

      public ItemQuery withId(int... ids)
      Keeps items whose id is one of ids; no ids leaves the query unchanged.
    • withAction

      public ItemQuery withAction(String... actions)
      Keeps items whose definition exposes at least one of the given actions (e.g. Eat).
    • filter

      public ItemQuery filter(Predicate<PrivItem> pred)
      Narrows this query in place and returns it. Queries are mutable and single-use; the predicate runs on the calling thread.
    • where

      public ItemQuery where(Predicate<PrivItem> pred)
    • sort

      public ItemQuery sort(Comparator<PrivItem> comparator)
      Sort the working list in place (e.g. ConsumableSelectionOrder.lowestPotionDoseThenLowestSlot()).
    • nonPlaceholder

      public ItemQuery nonPlaceholder()
      Drops empty or placeholder rows (id 0 or less).
    • quantityOver

      public ItemQuery quantityOver(int n)
      Keeps rows whose quantity is strictly greater than n.
    • quantityGreaterThan

      public ItemQuery quantityGreaterThan(int n)
      Same as quantityOver(int); KSBot-style name.
    • withSlot

      public ItemQuery withSlot(int slot)
      Keeps the row in container slot slot (0-based).
    • first

      public PrivItem first()
      The first remaining row (lowest slot first unless sorted), or null when empty.
    • first

      public PrivItem first(Predicate<PrivItem> pred)
      First slot matching pred without mutating the fluent chain’s prior filters incorrectly — uses a stream view.
    • empty

      public boolean empty()
      True when no row is left.
    • size

      public int size()
      The number of rows left (slots, not total quantity).
    • list

      public List<PrivItem> list()
      An unmodifiable view of the remaining rows.