InventoryQuery
Query class for searching and filtering items in an inventory.
ClassRLPlugins API
public class InventoryQuery extends AbstractQuery<ItemEx, InventoryQuery>Members
Constructors
- newInventoryQuery(List<ItemEx>)
Constructor to initialize the query with a list of items.
Methods
- intcount()
Count the total quantity of items left in the list - terminal operation.
- InventoryQueryfromContainer(ItemContainer)
Create a query from a standard ItemContainer instance.
- InventoryQueryfromContainer(ItemContainerEx)
Create a query from an ItemContainerEx instance.
- InventoryQueryfromCurrentShop()
Create a query from the currently open shop.
- InventoryQueryfromInventoryId(InventoryID)
Create a query from an InventoryID.
- InventoryQueryfromInventoryId(int)
Create a query from an inventory ID.
- InventoryQueryfromShop(Shop)
Create a query from a Shop enum.
- InventoryQueryfromSlot(int...)
Filter items by slots.
- intgetQuantity()
Get total quantity - terminal operation.
- longgetTotalGeValue()
Get total GE value - terminal operation.
- intgetTotalHighAlchValue()
Get total high alch value - terminal operation.
- intgetTotalShopValue()
Get total shop value - terminal operation.
- InventoryQuerygreaterThanGePrice(int)
Filter items with a GE price greater than the specified value.
- InventoryQuerygreaterThanHighAlchValue(int)
Filter items with a high alch value greater than the specified value.
- InventoryQuerygreaterThanLowAlchValue(int)
Filter items with a low alch value greater than the specified value.
- InventoryQuerygreaterThanShopPrice(int)
Filter items with a shop price greater than the specified value.
- InventoryQuerylessThanGePrice(int)
Filter items with a GE price less than the specified value.
- InventoryQuerylessThanHighAlchValue(int)
Filter items with a high alch value less than the specified value.
- InventoryQuerylessThanLowAlchValue(int)
Filter items with a low alch value less than the specified value.
- InventoryQuerylessThanShopPrice(int)
Filter items with a shop price less than the specified value.
- List<ItemEx>unique()
Unique.
- InventoryQuerywithAction(String)
Filter items by action.
- InventoryQuerywithActionContains(String)
Filter items whose actions contain the specified substring (case-insensitive).
- InventoryQuerywithCanonicalId(int...)
Filter items by their canonical IDs.
- InventoryQuerywithId(int...)
Filter items by their IDs.
- InventoryQuerywithName(String...)
Filter items by their names.
- InventoryQuerywithNameContains(String)
Filter items whose names contain the specified substring (case-insensitive).
- InventoryQuerywithNameMatches(String)
Filter items whose names match the specified wildcard pattern (case-insensitive).
Inherited from AbstractQuery
- Raggregate(Function<Stream<ItemEx>, R>)
Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
- booleanall(Predicate<ItemEx>)
Check if all filtered results match the predicate.
- booleanany(Predicate<ItemEx>)
Check if any filtered result matches the predicate.
- List<ItemEx>collect()
Get the filtered/sorted list.
- Rcollect(Collector<ItemEx, ?, R>)
Execute filters and process with custom collector.
- InventoryQuerydistinct()
Ensure results are distinct.
- ItemExfirst()
Get the first element from the filtered/sorted list.
- voidfirstIfPresent(Consumer<ItemEx>)
First if present.
- voidfirstOrElse(Consumer<ItemEx>, Runnable)
Perform action on the first element, or else run elseAction if no results.
- voidforEach(Consumer<ItemEx>)
Executes filters and performs an action on each result.
- booleanisEmpty()
Check if there are no filtered results.
- InventoryQuerykeepIf(Predicate<ItemEx>)
Lazily filter by predicate (keeps matching items).
- ItemExlast()
Get the last element from the filtered/sorted list.
- voidlastOrElse(Consumer<ItemEx>, Runnable)
Perform action on the last element, or else run elseAction if no results.
- InventoryQuerylimit(int)
Limit the number of results.
- booleannone(Predicate<ItemEx>)
Check if no filtered results match the predicate.
- InventoryQuerypeek(Consumer<ItemEx>)
Peek at each element during processing.
- InventoryQuerypostProcess(Function<List<ItemEx>, List<ItemEx>>)
Apply a post-processing function after sorting.
- ItemExrandom()
Get a random element from the filtered/sorted list.
- InventoryQueryremoveIf(Predicate<ItemEx>)
Lazily filter by predicate (removes matching items).
- InventoryQueryskip(int)
Skip a number of results.
- InventoryQuerysort(Comparator<ItemEx>)
Lazily add sorting.
InventoryQuery(List<ItemEx>)
public InventoryQuery(List<ItemEx> cache)Constructor to initialize the query with a list of items.
Parameters
cache- The initial list of items to query from.
count()
public int count()Count the total quantity of items left in the list - terminal operation.
Returns
The total quantity of items.
fromContainer(ItemContainer)static
public static InventoryQuery fromContainer(ItemContainer itemContainer)Create a query from a standard ItemContainer instance.
Parameters
itemContainer- The item container to query from.
Returns
A new InventoryQuery instance.
fromContainer(ItemContainerEx)static
public static InventoryQuery fromContainer(ItemContainerEx itemContainer)Create a query from an ItemContainerEx instance.
Parameters
itemContainer- The item container to query from.
Returns
A new InventoryQuery instance.
fromCurrentShop()static
public static InventoryQuery fromCurrentShop()Create a query from the currently open shop.
Returns
A new InventoryQuery instance, or empty if no shop is open.
fromInventoryId(InventoryID)static
public static InventoryQuery fromInventoryId(InventoryID inventoryId)Create a query from an InventoryID.
Parameters
inventoryId- The inventory ID to query from.
Returns
A new InventoryQuery instance.
fromInventoryId(int)static
public static InventoryQuery fromInventoryId(int inventoryId)Create a query from an inventory ID.
Parameters
inventoryId- The inventory ID to query from.
Returns
A new InventoryQuery instance.
fromShop(Shop)static
public static InventoryQuery fromShop(Shop shop)Create a query from a Shop enum.
Parameters
shop- The shop to query from.
Returns
A new InventoryQuery instance.
fromSlot(int...)
public InventoryQuery fromSlot(int... slots)Filter items by slots.
Parameters
slots- Slots.
Returns
InventoryQuery.
getQuantity()
public int getQuantity()Get total quantity - terminal operation.
getTotalGeValue()
public long getTotalGeValue()Get total GE value - terminal operation.
getTotalHighAlchValue()
public int getTotalHighAlchValue()Get total high alch value - terminal operation.
getTotalShopValue()
public int getTotalShopValue()Get total shop value - terminal operation.
greaterThanGePrice(int)
public InventoryQuery greaterThanGePrice(int price)Filter items with a GE price greater than the specified value.
Parameters
price- Price.
Returns
InventoryQuery.
greaterThanHighAlchValue(int)
public InventoryQuery greaterThanHighAlchValue(int value)Filter items with a high alch value greater than the specified value.
Parameters
value- Value.
Returns
InventoryQuery.
greaterThanLowAlchValue(int)
public InventoryQuery greaterThanLowAlchValue(int value)Filter items with a low alch value greater than the specified value.
Parameters
value- Value.
Returns
InventoryQuery.
greaterThanShopPrice(int)
public InventoryQuery greaterThanShopPrice(int price)Filter items with a shop price greater than the specified value.
Parameters
price- Price.
Returns
InventoryQuery.
lessThanGePrice(int)
public InventoryQuery lessThanGePrice(int price)Filter items with a GE price less than the specified value.
Parameters
price- Price.
Returns
InventoryQuery.
lessThanHighAlchValue(int)
public InventoryQuery lessThanHighAlchValue(int value)Filter items with a high alch value less than the specified value.
Parameters
value- Value.
Returns
InventoryQuery.
lessThanLowAlchValue(int)
public InventoryQuery lessThanLowAlchValue(int value)Filter items with a low alch value less than the specified value.
Parameters
value- Value.
Returns
InventoryQuery.
lessThanShopPrice(int)
public InventoryQuery lessThanShopPrice(int price)Filter items with a shop price less than the specified value.
Parameters
price- Price.
Returns
InventoryQuery.
unique()
public List<ItemEx> unique()Unique.
Returns
A list of items, only keeping a single instance of each item. Filtering out occurences of the same ID.
withAction(String)
public InventoryQuery withAction(String action)Filter items by action.
Parameters
action- Action.
Returns
InventoryQuery.
withActionContains(String)
public InventoryQuery withActionContains(String actionPart)Filter items whose actions contain the specified substring (case-insensitive).
Parameters
actionPart- Substring to search for in item actions.
Returns
InventoryQuery.
withCanonicalId(int...)
public InventoryQuery withCanonicalId(int... id)Filter items by their canonical IDs.
Parameters
id- Id.
Returns
InventoryQuery.
withId(int...)
public InventoryQuery withId(int... id)Filter items by their IDs.
Parameters
id- Id.
Returns
InventoryQuery.
withName(String...)
public InventoryQuery withName(String... name)Filter items by their names.
Parameters
name- Name.
Returns
InventoryQuery.
withNameContains(String)
public InventoryQuery withNameContains(String namePart)Filter items whose names contain the specified substring (case-insensitive).
Parameters
namePart- Substring to search for in item names.
Returns
InventoryQuery.
withNameMatches(String)
public InventoryQuery withNameMatches(String namePart)Filter items whose names match the specified wildcard pattern (case-insensitive).
Parameters
namePart- Wildcard pattern to match against item names.
Returns
InventoryQuery.
aggregate(Function<Stream<ItemEx>, R>)from AbstractQuery
public R aggregate(Function<Stream<ItemEx>, R> aggregator)Generic aggregation method for custom terminal operations Executes filters and allows custom stream processing.
Parameters
aggregator- Aggregator.
all(Predicate<ItemEx>)from AbstractQuery
public boolean all(Predicate<ItemEx> predicate)Check if all filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if all match, false otherwise.
any(Predicate<ItemEx>)from AbstractQuery
public boolean any(Predicate<ItemEx> predicate)Check if any filtered result matches the predicate.
Parameters
predicate- Predicate to test.
Returns
True if any match, false otherwise.
collect()from AbstractQuery
public List<ItemEx> collect()Get the filtered/sorted list.
collect(Collector<ItemEx, ?, R>)from AbstractQuery
public R collect(Collector<ItemEx, ?, R> collector)Execute filters and process with custom collector.
Parameters
collector- Collector.
distinct()from AbstractQuery
public InventoryQuery distinct()Ensure results are distinct.
Returns
The query instance.
first()from AbstractQuery
public ItemEx first()Get the first element from the filtered/sorted list.
firstIfPresent(Consumer<ItemEx>)from AbstractQuery
public void firstIfPresent(Consumer<ItemEx> action)First if present.
Parameters
action- Action.
firstOrElse(Consumer<ItemEx>, Runnable)from AbstractQuery
public void firstOrElse(Consumer<ItemEx> action, Runnable elseAction)Perform action on the first element, or else run elseAction if no results.
Parameters
action- Action to perform on the first element.
elseAction- Action to perform if no results.
forEach(Consumer<ItemEx>)from AbstractQuery
public void forEach(Consumer<ItemEx> action)Executes filters and performs an action on each result.
Parameters
action- Action.
isEmpty()from AbstractQuery
public boolean isEmpty()Check if there are no filtered results.
Returns
True if no results after filtering, false otherwise.
keepIf(Predicate<ItemEx>)from AbstractQuery
public InventoryQuery keepIf(Predicate<ItemEx> predicate)Lazily filter by predicate (keeps matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
last()from AbstractQuery
public ItemEx last()Get the last element from the filtered/sorted list.
lastOrElse(Consumer<ItemEx>, Runnable)from AbstractQuery
public void lastOrElse(Consumer<ItemEx> action, Runnable elseAction)Perform action on the last element, or else run elseAction if no results.
Parameters
action- Action to perform on the last element.
elseAction- Action to perform if no results.
limit(int)from AbstractQuery
public InventoryQuery limit(int maxSize)Limit the number of results.
Parameters
maxSize- Max size.
Returns
The query instance.
none(Predicate<ItemEx>)from AbstractQuery
public boolean none(Predicate<ItemEx> predicate)Check if no filtered results match the predicate.
Parameters
predicate- Predicate to test.
Returns
True if none match, false otherwise.
peek(Consumer<ItemEx>)from AbstractQuery
public InventoryQuery peek(Consumer<ItemEx> action)Peek at each element during processing.
Parameters
action- Action to perform on each element.
Returns
The query instance.
postProcess(Function<List<ItemEx>, List<ItemEx>>)from AbstractQuery
public InventoryQuery postProcess(Function<List<ItemEx>, List<ItemEx>> processor)Apply a post-processing function after sorting.
Useful for reordering algorithms that can't be expressed as Comparators.
Parameters
processor- Function to transform the result list.
Returns
The query instance.
random()from AbstractQuery
public ItemEx random()Get a random element from the filtered/sorted list.
removeIf(Predicate<ItemEx>)from AbstractQuery
public InventoryQuery removeIf(Predicate<ItemEx> predicate)Lazily filter by predicate (removes matching items).
Parameters
predicate- Predicate.
Returns
The query instance.
skip(int)from AbstractQuery
public InventoryQuery skip(int count)Skip a number of results.
Parameters
count- Count.
Returns
The query instance.
sort(Comparator<ItemEx>)from AbstractQuery
public InventoryQuery sort(Comparator<ItemEx> comparator)Lazily add sorting.
Parameters
comparator- Comparator.
Returns
The query instance.
Also allowed
Every class has these, as in plain Java.
equals, toString