Class StoragePreconditions
java.lang.Object
net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions
Preconditions that can be used when working with storages.
In particular, notNegative(long)
or notBlankNotNegative(net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant<?>, long)
can be used by implementations of
Storage.insert(T, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext)
and Storage.extract(T, long, net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext)
to fail-fast if the arguments are invalid.
Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
notBlank
(TransferVariant<?> variant) Ensure that the passed transfer variant is not blank.static void
notBlankNotNegative
(TransferVariant<?> variant, long amount) Check both for a not blank transfer variant and a not negative amount.static void
notNegative
(long amount) Ensure that the passed amount is not negative.
-
Method Details
-
notBlank
Ensure that the passed transfer variant is not blank.- Throws:
IllegalArgumentException
- If the variant is blank.
-
notNegative
public static void notNegative(long amount) Ensure that the passed amount is not negative. That is, it must be>= 0
.- Throws:
IllegalArgumentException
- If the amount is negative.
-
notBlankNotNegative
Check both for a not blank transfer variant and a not negative amount.
-