Package org.johnnei.javatorrent.utils
Class Argument
- java.lang.Object
-
- org.johnnei.javatorrent.utils.Argument
-
public class Argument extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> TrequireNonNull(T object, String message)Tests for null and throwsIllegalArgumentExceptionwhen null.static voidrequirePositive(int amount, String message)Tests if the given integer is positive.static voidrequireWithinBounds(int amount, int lowerLimit, int upperLimit, String message)Deprecated.Replaced byrequireWithinBounds(int, int, int, Supplier)static voidrequireWithinBounds(int amount, int lowerLimit, int upperLimit, Supplier<String> message)Tests if the given amount is within the bounds.
-
-
-
Method Detail
-
requireNonNull
public static <T> T requireNonNull(T object, String message)Tests for null and throwsIllegalArgumentExceptionwhen null.- Type Parameters:
T- The type- Parameters:
object- The object to test.message- The message when it is null.- Returns:
- The object instance when non-null.
-
requirePositive
public static void requirePositive(int amount, String message)Tests if the given integer is positive.- Parameters:
amount- The amount to test.message- The message when the amount is negative.
-
requireWithinBounds
public static void requireWithinBounds(int amount, int lowerLimit, int upperLimit, Supplier<String> message)Tests if the given amount is within the bounds.- Parameters:
amount- The amount to testlowerLimit- The lower limit (inclusive)upperLimit- The upper limit (exclusive)
-
requireWithinBounds
@Deprecated public static void requireWithinBounds(int amount, int lowerLimit, int upperLimit, String message)
Deprecated.Replaced byrequireWithinBounds(int, int, int, Supplier)Tests if the given amount is within the bounds.- Parameters:
amount- The amount to testlowerLimit- The lower limit (inclusive)upperLimit- The upper limit (exclusive)
-
-