Class Required
- java.lang.Object
-
- net.sourceforge.uiq3.Required
-
public final class Required extends Object
A utility class to check method parameter
- Since:
- 1.0
- Version:
- 1.0 $Revision: 7681 $
- Author:
- "Martin Krischik" «krischik@users.sourceforge.net»
-
-
Constructor Summary
Constructors Modifier Constructor Description privateRequired()Utility class, do not create
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidequal(int left, int right)test if a string lengths is inside the range min … maxstatic voidequal(int left, int right, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidequal(long left, long right)test if a string lengths is inside the range min … maxstatic voidequal(long left, long right, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidequal(@NotNull Enum<?> left, @NotNull Enum<?> right, @NotNull String name)test if two enums are the same.static voidequal(String left, String right)test if a string lengths is inside the range min … maxstatic voidequal(String left, String right, String name)test if a string lengths is inside the range min … maxstatic voidgreaterEqual(long left, long right)test if a string lengths is inside the range min … maxstatic voidgreaterEqual(long left, long right, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidisFalse(boolean value)test if a string lengths is inside the range min … maxstatic voidisFalse(boolean value, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidisInstance(@NotNull Object value, @NotNull Class<?> type)test if a string lengths is inside the range min … maxstatic voidisInstance(@NotNull Object value, @NotNull Class<?> type, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidisNatural(int value)test if a numeric value is greater or equal 0static voidisNatural(int value, @NotNull String name)test if a numeric value is greater or equal 0static voidisNull(@Nullable Object value)test if a string lengths is inside the range min … maxstatic voidisNull(@Nullable Object value, @NotNull String name)test if an instance is nullstatic voidisPositive(int value)test if a numeric value is greater or equal 1static voidisPositive(int value, @NotNull String name)test if a numeric value is greater or equal 1static voidisTrue(boolean value)test if a string lengths is inside the range min … maxstatic voidisTrue(boolean value, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidnotEmpty(@Nullable String value)test if a string lengths is not emptystatic voidnotEmpty(@Nullable String value, @NotNull String name)test if a string lengths is not emptystatic voidnotNull(@Nullable Object value)test if an instance is not nullstatic voidnotNull(@Nullable Object value, @NotNull String name)test if a string lengths is inside the range min … maxstatic voidrange(byte value, byte min, byte max)test if a numeric value is inside the range min … maxstatic voidrange(byte value, byte min, byte max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(double value, double min, double max)test if a numeric value is inside the range min … maxstatic voidrange(double value, double min, double max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(float value, float min, float max)test if a numeric value is inside the range min … maxstatic voidrange(float value, float min, float max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(int value, int min, int max)test if a numeric value is inside the range min … maxstatic voidrange(int value, int min, int max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(long value, long min, long max)test if a numeric value is inside the range min … maxstatic voidrange(long value, long min, long max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(short value, short min, short max)test if a numeric value is inside the range min … maxstatic voidrange(short value, short min, short max, @NotNull String name)test if a numeric value is inside the range min … maxstatic voidrange(@NotNull CharSequence value, int min, int max)test if a string length is inside the range min … maxstatic voidrange(@NotNull CharSequence value, int min, int max, @NotNull String name)test if a string length is inside the range min … maxstatic voidrange(@NotNull Object @NotNull [] value, int min, int max)test if a string length is inside the range min … maxstatic voidrange(@NotNull Object @NotNull [] value, int min, int max, @NotNull String name)test if a string length is inside the range min … maxstatic voidrangeOrNull(@Nullable CharSequence value, int min, int max)test if a string length is inside the range min … maxstatic voidrangeOrNull(@Nullable CharSequence value, int min, int max, @NotNull String name)test if a string length is inside the range min … max
-
-
-
Method Detail
-
equal
public static void equal(int left, int right)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(int left, int right, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(long left, long right)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(long left, long right, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(@NotNull @NotNull Enum<?> left, @NotNull @NotNull Enum<?> right, @NotNull @NotNull String name)test if two enums are the same.
- Parameters:
left- value to testright- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(String left, String right)
test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
equal
public static void equal(String left, String right, String name)
test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
greaterEqual
public static void greaterEqual(long left, long right)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
greaterEqual
public static void greaterEqual(long left, long right, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
left- value to testright- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
isFalse
@Contract("true -> fail") public static void isFalse(boolean value)test if a string lengths is inside the range min … max
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
isFalse
@Contract("true, _ -> fail") public static void isFalse(boolean value, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
isInstance
public static void isInstance(@NotNull @NotNull Object value, @NotNull @NotNull Class<?> type)test if a string lengths is inside the range min … max
- Parameters:
value- value to testtype- type to check against- Throws:
IllegalArgumentException- when value is outside min … max
-
isInstance
public static void isInstance(@NotNull @NotNull Object value, @NotNull @NotNull Class<?> type, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
value- value to testtype- type to check againstname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
isNatural
public static void isNatural(int value)
test if a numeric value is greater or equal 0
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when value is not not greater 0
-
isNatural
public static void isNatural(int value, @NotNull @NotNull String name)test if a numeric value is greater or equal 0
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is not greater or equal 0
-
isNull
@Contract("!null -> fail") public static void isNull(@Nullable @Nullable Object value)test if a string lengths is inside the range min … max
- Parameters:
value- value to test- Throws:
AssertionError- when value is outside min … max
-
isNull
@Contract("!null, _ -> fail") public static void isNull(@Nullable @Nullable Object value, @NotNull @NotNull String name)test if an instance is null
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when the instance is null
-
isPositive
public static void isPositive(int value)
test if a numeric value is greater or equal 1
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when value is not greater or equal 1
-
isPositive
public static void isPositive(int value, @NotNull @NotNull String name)test if a numeric value is greater or equal 1
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is not greater or equal 1
-
isTrue
@Contract("false -> fail") public static void isTrue(boolean value)test if a string lengths is inside the range min … max
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
isTrue
@Contract("false, _ -> fail") public static void isTrue(boolean value, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
notEmpty
public static void notEmpty(@Nullable @Nullable String value)test if a string lengths is not empty
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when value is outside min … max
-
notEmpty
public static void notEmpty(@Nullable @Nullable String value, @NotNull @NotNull String name)test if a string lengths is not empty
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
notNull
@Contract("null -> fail") public static void notNull(@Nullable @Nullable Object value)test if an instance is not null
- Parameters:
value- value to test- Throws:
IllegalArgumentException- when the instance is null
-
notNull
@Contract("null, _ -> fail") public static void notNull(@Nullable @Nullable Object value, @NotNull @NotNull String name)test if a string lengths is inside the range min … max
- Parameters:
value- value to testname- value name for better error message- Throws:
IllegalArgumentException- when the instance is null
-
range
public static void range(byte value, byte min, byte max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(byte value, byte min, byte max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(@NotNull @NotNull CharSequence value, int min, int max)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(@NotNull @NotNull CharSequence value, int min, int max, @NotNull @NotNull String name)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(double value, double min, double max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(double value, double min, double max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(float value, float min, float max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(float value, float min, float max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(int value, int min, int max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(int value, int min, int max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(long value, long min, long max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(long value, long min, long max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(@NotNull @NotNull Object @NotNull [] value, int min, int max)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(@NotNull @NotNull Object @NotNull [] value, int min, int max, @NotNull @NotNull String name)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(short value, short min, short max)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
range
public static void range(short value, short min, short max, @NotNull @NotNull String name)test if a numeric value is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
rangeOrNull
public static void rangeOrNull(@Nullable @Nullable CharSequence value, int min, int max)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed value- Throws:
IllegalArgumentException- when value is outside min … max
-
rangeOrNull
public static void rangeOrNull(@Nullable @Nullable CharSequence value, int min, int max, @NotNull @NotNull String name)test if a string length is inside the range min … max
- Parameters:
value- value to testmin- minimum allowed valuemax- maximum allowed valuename- value name for better error message- Throws:
IllegalArgumentException- when value is outside min … max
-
-