Class ItemQuery

All Implemented Interfaces:
Predicate<IItem>

public class ItemQuery extends Query<IItem,ItemQuery,ItemQueryResults>
Query class for finding and filtering items in containers such as inventory, bank, or equipment.

This class provides comprehensive filtering capabilities for items:

  • Filter by item IDs
  • Filter by noted item IDs
  • Filter by inventory slots
  • Filter by item names
  • Filter by available actions
  • Filter by tradability
  • Filter by stackability
  • Filter by members-only status
  • Filter by noted status

Example usage:


 // Find all tradable food items in inventory
 ItemQuery query = new ItemQuery(inventorySupplier)
     .actions("Eat")
     .tradable(true);
 ItemQueryResults results = query.results();
 
  • Constructor Details

    • ItemQuery

      public ItemQuery(Supplier<List<IItem>> supplier)
      Constructs a new item query with the specified item supplier.
      Parameters:
      supplier - a supplier that provides the list of items to query
  • Method Details

    • ids

      public ItemQuery ids(int... ids)
      Filters items by their IDs.

      Only items with an ID matching one of the specified values will be included.

      Parameters:
      ids - the item IDs to filter by
      Returns:
      this query instance for method chaining
    • notedIds

      public ItemQuery notedIds(int... notedIds)
      Filters items by their noted IDs.

      Only items with a noted ID matching one of the specified values will be included.

      Parameters:
      notedIds - the noted item IDs to filter by
      Returns:
      this query instance for method chaining
    • slots

      public ItemQuery slots(int... slots)
      Filters items by their inventory slot positions.

      Only items located in one of the specified slots will be included.

      Parameters:
      slots - the slot positions to filter by
      Returns:
      this query instance for method chaining
    • names

      public ItemQuery names(String... names)
      Filters items by their names using exact matching.

      Only items whose name exactly matches one of the specified values will be included.

      Parameters:
      names - the item names to filter by
      Returns:
      this query instance for method chaining
    • actions

      public ItemQuery actions(String... actions)
      Filters items by their available actions.

      Only items that have at least one action matching one of the specified values will be included.

      Parameters:
      actions - the actions to filter by
      Returns:
      this query instance for method chaining
    • tradable

      public ItemQuery tradable(boolean tradable)
      Filters items by their tradability.

      Only items whose tradability matches the specified value will be included.

      Parameters:
      tradable - true to include only tradable items, false for untradable items
      Returns:
      this query instance for method chaining
    • stackable

      public ItemQuery stackable(boolean stackable)
      Filters items by their stackability.

      Only items whose stackability matches the specified value will be included.

      Parameters:
      stackable - true to include only stackable items, false for non-stackable items
      Returns:
      this query instance for method chaining
    • members

      public ItemQuery members(boolean members)
      Filters items by their members-only status.

      Only items whose members status matches the specified value will be included.

      Parameters:
      members - true to include only members items, false for free-to-play items
      Returns:
      this query instance for method chaining
    • noted

      public ItemQuery noted(boolean noted)
      Filters items by their noted status.

      Only items whose noted status matches the specified value will be included.

      Parameters:
      noted - true to include only noted items, false for unnoted items
      Returns:
      this query instance for method chaining
    • results

      protected ItemQueryResults results(List<IItem> list)
      Wraps the filtered list of items in an ItemQueryResults container.
      Specified by:
      results in class Query<IItem,ItemQuery,ItemQueryResults>
      Parameters:
      list - the list of items that passed all filters
      Returns:
      the results wrapped in an ItemQueryResults container
    • test

      public boolean test(IItem item)
      Tests whether an item passes all accumulated filter criteria.

      This method checks the item against all configured filters including ID, noted ID, slot, name, actions, tradability, stackability, members status, and noted status.

      Specified by:
      test in interface Predicate<IItem>
      Overrides:
      test in class Query<IItem,ItemQuery,ItemQueryResults>
      Parameters:
      item - the item to test
      Returns:
      true if the item passes all filters, false otherwise