public class Require extends Object
Objects.requireNonNull(Object,String) approach
but provides null-safe operations for the most common checks over Objects,
Strings, Collections, Maps, arrays and objects that implement
the Emptily interface.
This class is designed primarily for doing parameter validation in methods and constructors, like the following:
public MyClass( int id, Foo foo, String bar )
{
this.id = Require.trueFor( id, id > 0, "id must be positive" );
this.foo = Require.nonNull( foo, "foo cannot be null" );
this.val = Require.nonBlank( val, "val cannot be blank" );
}
The checks currently implemented are:
true otherwise throws a RequirementFailureRequirementFailurenull otherwise throws a RequirementFailureRequirementFailureString to be not blank otherwise throws a RequirementFailure| Modifier and Type | Method and Description |
|---|---|
static String |
nonBlank(String value)
Checks that the specified
String satisfies IsNot.blank(String). |
static String |
nonBlank(String value,
String message)
Checks that the specified
String satisfies IsNot.blank(String)
and throws a customized RequirementFailure if not. |
static String |
nonBlank(String value,
Supplier<String> messageSupplier)
Checks that the specified
String satisfies IsNot.blank(String)
and throws a customized RequirementFailure if not. |
static boolean[] |
nonEmpty(boolean[] value)
Checks that the specified
array reference is not null nor empty. |
static boolean[] |
nonEmpty(boolean[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static boolean[] |
nonEmpty(boolean[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static byte[] |
nonEmpty(byte[] value)
Checks that the specified
array reference is not null nor empty. |
static byte[] |
nonEmpty(byte[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static byte[] |
nonEmpty(byte[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V,C extends Collection<V>> |
nonEmpty(C value)
Checks that the specified
Collection reference is not null nor empty. |
static char[] |
nonEmpty(char[] value)
Checks that the specified
array reference is not null nor empty. |
static char[] |
nonEmpty(char[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static char[] |
nonEmpty(char[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V,C extends Collection<V>> |
nonEmpty(C value,
String message)
Checks that the specified
Collection reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V,C extends Collection<V>> |
nonEmpty(C value,
Supplier<String> messageSupplier)
Checks that the specified
Collection reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static double[] |
nonEmpty(double[] value)
Checks that the specified
array reference is not null nor empty. |
static double[] |
nonEmpty(double[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static double[] |
nonEmpty(double[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static Emptily |
nonEmpty(Emptily value)
Checks that the specified
Emptily reference is not null nor empty. |
static Emptily |
nonEmpty(Emptily value,
String message)
Checks that the specified
Emptily reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static Emptily |
nonEmpty(Emptily value,
Supplier<String> messageSupplier)
Checks that the specified
Emptily reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static float[] |
nonEmpty(float[] value)
Checks that the specified
array reference is not null nor empty. |
static float[] |
nonEmpty(float[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static float[] |
nonEmpty(float[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static int[] |
nonEmpty(int[] value)
Checks that the specified
array reference is not null nor empty. |
static int[] |
nonEmpty(int[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static int[] |
nonEmpty(int[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static long[] |
nonEmpty(long[] value)
Checks that the specified
array reference is not null nor empty. |
static long[] |
nonEmpty(long[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static long[] |
nonEmpty(long[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <K,V,M extends Map<K,V>> |
nonEmpty(M value)
Checks that the specified
Map reference is not null nor empty. |
static <K,V,M extends Map<K,V>> |
nonEmpty(M value,
String message)
Checks that the specified
Map reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <K,V,M extends Map<K,V>> |
nonEmpty(M value,
Supplier<String> messageSupplier)
Checks that the specified
Map reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static short[] |
nonEmpty(short[] value)
Checks that the specified
array reference is not null nor empty. |
static short[] |
nonEmpty(short[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static short[] |
nonEmpty(short[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static String |
nonEmpty(String value)
Checks that the specified
String reference is not null nor empty. |
static String |
nonEmpty(String value,
String message)
Checks that the specified
String reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static String |
nonEmpty(String value,
Supplier<String> messageSupplier)
Checks that the specified
String reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V> V[] |
nonEmpty(V[] value)
Checks that the specified
array reference is not null nor empty. |
static <V> V[] |
nonEmpty(V[] value,
String message)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V> V[] |
nonEmpty(V[] value,
Supplier<String> messageSupplier)
Checks that the specified
array reference is not null nor empty
and throws a customized RequirementFailure if it is. |
static <V> V |
nonNull(V value)
Checks that the specified object reference is not
null. |
static <V> V |
nonNull(V value,
String message)
Checks that the specified object reference is not
null and
throws a customized RequirementFailure if it is. |
static <V> V |
nonNull(V value,
Supplier<String> messageSupplier)
Checks that the specified object reference is not
null and
throws a customized RequirementFailure if it is. |
static void |
toHold(boolean assertion)
Checks the given assertion to be
true. |
static void |
toHold(boolean assertion,
String message)
Checks the given assertion to be
true and
throws a customized RequirementFailure if not. |
static void |
toHold(boolean assertion,
Supplier<String> messageSupplier)
Checks the given assertion to be
true and
throws a customized RequirementFailure if not. |
static <V> V |
trueFor(V value,
boolean assertion)
Checks the given assertion to hold for the specified value.
|
static <V> V |
trueFor(V value,
boolean assertion,
String message)
Checks the given assertion to hold for the specified value
and throws a customized
RequirementFailure if not. |
static <V> V |
trueFor(V value,
boolean assertion,
Supplier<String> messageSupplier)
Checks the given assertion to hold for the specified value.
|
public static void toHold(boolean assertion)
true.assertion - the assertion that has to be trueRequirementFailure - if the assertion is falsepublic static void toHold(boolean assertion,
String message)
true and
throws a customized RequirementFailure if not.assertion - the assertion that has to be truemessage - detail message to be used in the event that a
RequirementFailure is thrownRequirementFailure - if the assertion is falsepublic static void toHold(boolean assertion,
Supplier<String> messageSupplier)
true and
throws a customized RequirementFailure if not.
Unlike the method toHold(boolean, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
assertion - the assertion that has to be truemessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownRequirementFailure - if the assertion is falsepublic static <V> V trueFor(V value,
boolean assertion)
The assertion passed to this method should check some property of the given value. If the assertion holds the related value will be returned.
V - the type of the value.value - the value to be checked.assertion - the assertion relating to the given value that has to be truevalue if the related assertion holds.RequirementFailure - if the assertion is false,
the given value otherwise.public static <V> V trueFor(V value,
boolean assertion,
String message)
RequirementFailure if not.
The assertion passed to this method should check some property of the given value. If the assertion holds the related value will be returned
V - the type of the value.value - the value to be checked.assertion - the assertion that has to be truemessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if the related assertion holds.RequirementFailure - if the assertion is false,
the given value otherwise.public static <V> V trueFor(V value,
boolean assertion,
Supplier<String> messageSupplier)
RequirementFailure if not.
The assertion passed to this method should check some property of the given value. If the assertion holds the related value will be returned.
Unlike the method trueFor(Object,boolean,String),
this method allows creation of the message to be deferred until
after the assertion check is made. While this may confer a
performance advantage in the good case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
V - the type of the value.value - the value to be checked.assertion - the assertion that has to be truemessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if the related assertion holds.RequirementFailure - if the assertion is false,
the given value otherwise.public static <V> V nonNull(V value)
null.V - the type of the referencevalue - the object reference to check for nullityvalue if not nullRequirementFailure - if value is nullpublic static <V> V nonNull(V value,
String message)
null and
throws a customized RequirementFailure if it is.V - the type of the referencevalue - the object reference to check for nullitymessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not nullRequirementFailure - if value is nullpublic static <V> V nonNull(V value,
Supplier<String> messageSupplier)
null and
throws a customized RequirementFailure if it is.
Unlike the method nonNull(Object, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
V - the type of the referencevalue - the object reference to check for nullitymessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not nullRequirementFailure - if value is nullpublic static Emptily nonEmpty(Emptily value)
Emptily reference is not null nor empty.value - the Emptily reference to check for emptinessvalue if not null nor emptyRequirementFailure - if value is nullpublic static Emptily nonEmpty(Emptily value, String message)
Emptily reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the Emptily reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static Emptily nonEmpty(Emptily value, Supplier<String> messageSupplier)
Emptily reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Emptily, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the Emptily reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static String nonEmpty(String value)
String reference is not null nor empty.value - the String reference to check for emptinessvalue if not null nor emptyRequirementFailure - if value is nullpublic static String nonEmpty(String value, String message)
String reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the String reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static String nonEmpty(String value, Supplier<String> messageSupplier)
String reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(String, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the String reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static String nonBlank(String value)
String satisfies IsNot.blank(String).value - the String reference to checkvalue if satisfies IsNot.blank(String)RequirementFailure - if the check failspublic static String nonBlank(String value, String message)
String satisfies IsNot.blank(String)
and throws a customized RequirementFailure if not.value - the String reference to checkmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if satisfies IsNot.blank(String)RequirementFailure - if the check failspublic static String nonBlank(String value, Supplier<String> messageSupplier)
String satisfies IsNot.blank(String)
and throws a customized RequirementFailure if not.
Unlike the method nonEmpty(String, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the String reference to checkmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if satisfies IsNot.blank(String)RequirementFailure - if the check failspublic static <V,C extends Collection<V>> C nonEmpty(C value)
Collection reference is not null nor empty.V - the type of the elements in the CollectionC - the actual implementation of the Collectionvalue - the Collection reference to check for emptinessvalue if not null nor emptyRequirementFailure - if value is nullpublic static <V,C extends Collection<V>> C nonEmpty(C value, String message)
Collection reference is not null nor empty
and throws a customized RequirementFailure if it is.V - the type of the elements in the CollectionC - the actual implementation of the Collectionvalue - the Collection reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static <V,C extends Collection<V>> C nonEmpty(C value, Supplier<String> messageSupplier)
Collection reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Collection, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
V - the type of the elements in the CollectionC - the actual implementation of the Collectionvalue - the Collection reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static <K,V,M extends Map<K,V>> M nonEmpty(M value)
Map reference is not null nor empty.K - the type of the key elements in the MapV - the type of the value elements in the MapM - the actual implementation of the Mapvalue - the Map reference to check for emptinessvalue if not null nor emptyRequirementFailure - if value is nullpublic static <K,V,M extends Map<K,V>> M nonEmpty(M value, String message)
Map reference is not null nor empty
and throws a customized RequirementFailure if it is.K - the type of the key elements in the MapV - the type of the value elements in the MapM - the actual implementation of the Mapvalue - the Map reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static <K,V,M extends Map<K,V>> M nonEmpty(M value, Supplier<String> messageSupplier)
Map reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
K - the type of the key elements in the MapV - the type of the value elements in the MapM - the actual implementation of the Mapvalue - the Map reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if value is null nor emptypublic static <V> V[] nonEmpty(V[] value)
array reference is not null nor empty.V - the type of the elements in the arrayvalue - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static <V> V[] nonEmpty(V[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.V - the type of the elements in the arrayvalue - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static <V> V[] nonEmpty(V[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
V - the type of the elements in the arrayvalue - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static boolean[] nonEmpty(boolean[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static boolean[] nonEmpty(boolean[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static boolean[] nonEmpty(boolean[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static char[] nonEmpty(char[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static char[] nonEmpty(char[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static char[] nonEmpty(char[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static byte[] nonEmpty(byte[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static byte[] nonEmpty(byte[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static byte[] nonEmpty(byte[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static short[] nonEmpty(short[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static short[] nonEmpty(short[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static short[] nonEmpty(short[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static int[] nonEmpty(int[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static int[] nonEmpty(int[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static int[] nonEmpty(int[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static float[] nonEmpty(float[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static float[] nonEmpty(float[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static float[] nonEmpty(float[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static long[] nonEmpty(long[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static long[] nonEmpty(long[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static long[] nonEmpty(long[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static double[] nonEmpty(double[] value)
array reference is not null nor empty.value - the array reference to check for emptinessvalue if not null nor emptyRequirementFailure - if the check failspublic static double[] nonEmpty(double[] value,
String message)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.value - the array reference to check for emptinessmessage - detail message to be used in the event that a
RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failspublic static double[] nonEmpty(double[] value,
Supplier<String> messageSupplier)
array reference is not null nor empty
and throws a customized RequirementFailure if it is.
Unlike the method nonEmpty(Map, String),
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
value - the array reference to check for emptinessmessageSupplier - supplier of the detail message to be
used in the event that a RequirementFailure is thrownvalue if not null nor emptyRequirementFailure - if the check failsCopyright © 2011–2020 Nerd4j. All rights reserved.