Package net.okocraft.box.api.transaction
Class StockHolderTransaction
java.lang.Object
net.okocraft.box.api.transaction.StockHolderTransaction
A utility class for transacting items between
StockHolder
and Inventory
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface to deposit items toStockHolder
.static interface
An interface to withdraw items fromStockHolder
. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StockHolderTransaction
create
(@NotNull StockHolder stockHolder) Creates aStockHolderTransaction
.@NotNull StockHolderTransaction.Deposit
Creates aStockHolderTransaction.Deposit
instance that depositing the specifiedBoxItem
.@NotNull StockHolderTransaction.Deposit
Creates aStockHolderTransaction.Deposit
instance that depositing all items that can be deposited.@NotNull StockHolderTransaction.Deposit
depositAll
(@NotNull Predicate<BoxItem> filter) Creates aStockHolderTransaction.Deposit
instance that depositing filtered items that can be deposited.@NotNull StockHolderTransaction.Withdrawal
Creates aStockHolderTransaction.Withdrawal
instance that withdrawing the specifiedBoxItem
.
-
Method Details
-
create
@Contract("_ -> new") @NotNull public static @NotNull StockHolderTransaction create(@NotNull @NotNull StockHolder stockHolder) Creates aStockHolderTransaction
.- Parameters:
stockHolder
- aStockHolder
to transact- Returns:
- a new
StockHolderTransaction
- Throws:
NullPointerException
- ifstockHolder
is null
-
deposit
@NotNull public @NotNull StockHolderTransaction.Deposit deposit(@NotNull @NotNull BoxItem item, int limit) Creates aStockHolderTransaction.Deposit
instance that depositing the specifiedBoxItem
.- Parameters:
item
- aBoxItem
to deposit to theStockHolder
limit
- a maximum amount to deposit- Returns:
- a
StockHolderTransaction.Deposit
instance - Throws:
NullPointerException
- ifitem
is null
-
depositAll
Creates aStockHolderTransaction.Deposit
instance that depositing all items that can be deposited.- Returns:
- a
StockHolderTransaction.Deposit
instance
-
depositAll
@NotNull public @NotNull StockHolderTransaction.Deposit depositAll(@NotNull @NotNull Predicate<BoxItem> filter) Creates aStockHolderTransaction.Deposit
instance that depositing filtered items that can be deposited.- Parameters:
filter
- aPredicate
to filterBoxItem
s- Returns:
- a
StockHolderTransaction.Deposit
instance - Throws:
NullPointerException
- iffilter
is null
-
withdraw
@NotNull public @NotNull StockHolderTransaction.Withdrawal withdraw(@NotNull @NotNull BoxItem item, int limit) Creates aStockHolderTransaction.Withdrawal
instance that withdrawing the specifiedBoxItem
.- Parameters:
item
- aBoxItem
to withdraw from theStockHolder
limit
- a maximum amount to withdraw- Returns:
- a
StockHolderTransaction.Withdrawal
instance - Throws:
NullPointerException
- ifitem
is null
-