public class Is extends Object
static utility methods intended
to operate boolean checks on objects.
This class provides null-safe operations for the most
common checks over Objects, Strings, Collections
Maps, arrays and objects that implement the Emptily interface.
The main aim of this class is to provide an easy and readable way
to perform the most common checks in conditional statements and in
functional statements like those provided by Stream
and Optional.
Object is nullString, a Collection, a Map, an array
or an implementation of the Emptily interface is emptyString contains only characters satisfying Character.isWhitespace(char)
This utility class can be used in if statements like:
if( Is.empty(collection) )
// Do something
if( Is.blank(string) )
// Do something
or can be used as Predicates in statements like:
collection.stream().filter( Is::NULL ) // Do something or optional.filter( Is::blank ) // Do something
| Modifier and Type | Method and Description |
|---|---|
static boolean |
blank(String value)
Checks if the given value is
null, empty
or contains only characters that satisfies the
check performed by Character.isWhitespace(char). |
static boolean |
empty(boolean[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(byte[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(char[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(Collection<?> value)
Checks if the given value is
null or empty. |
static boolean |
empty(double[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(Emptily value)
Checks if the given value is
null or empty. |
static boolean |
empty(float[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(int[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(long[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(Map<?,?> value)
Checks if the given value is
null or empty. |
static boolean |
empty(short[] value)
Checks if the given value is
null or empty. |
static boolean |
empty(String value)
Checks if the given value is
null or empty. |
static <V> boolean |
empty(V[] value)
Checks if the given value is
null or empty. |
static boolean |
NULL(Object value)
Checks if the given value is
null. |
public static boolean NULL(Object value)
null.
Since null is a keyword and therefore
cannot be used as a method name, we choose
to name the method in upper case.
value - the value to check.true if the value is null.public static boolean empty(Emptily value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(String value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean blank(String value)
null, empty
or contains only characters that satisfies the
check performed by Character.isWhitespace(char).value - the value to check.true if the value is null, empty
or contains only white spaces.public static boolean empty(Collection<?> value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(Map<?,?> value)
null or empty.value - the value to check.true if the value is null or empty.public static <V> boolean empty(V[] value)
null or empty.V - type of the elements in the array.value - the value to check.true if the value is null or empty.public static boolean empty(boolean[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(char[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(byte[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(short[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(int[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(float[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(long[] value)
null or empty.value - the value to check.true if the value is null or empty.public static boolean empty(double[] value)
null or empty.value - the value to check.true if the value is null or empty.Copyright © 2011–2020 Nerd4j. All rights reserved.