Class ObjectUtils
- java.lang.Object
-
- gov.nist.secauto.metaschema.core.util.ObjectUtils
-
public final class ObjectUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
asNullableType(Object obj)
static <T> T
asType(Object obj)
static <T> Stream<T>
filterNull(T item)
A filter used to remove null items from a stream.static <T> T
notNull(T obj)
Assert that the provided object is notnull
.static <T> T
requireNonNull(T obj)
Require a non-null value.static <T> T
requireNonNull(T obj, String message)
Require a non-null value.
-
-
-
Method Detail
-
notNull
@NonNull public static <T> T notNull(T obj)
Assert that the provided object is notnull
.This method sets the expectation that the provided object is not
null
in cases where a non-null value is required.- Type Parameters:
T
- the object type- Parameters:
obj
- the object- Returns:
- the object
-
requireNonNull
@NonNull public static <T> T requireNonNull(T obj)
Require a non-null value.- Type Parameters:
T
- the type of the reference- Parameters:
obj
- the object reference to check for nullity- Returns:
obj
if notnull
- Throws:
NullPointerException
- ifobj
isnull
-
requireNonNull
@NonNull public static <T> T requireNonNull(T obj, @NonNull String message)
Require a non-null value.- Type Parameters:
T
- the type of the reference- Parameters:
obj
- the object reference to check for nullitymessage
- detail message to be used in the event that aNullPointerException
is thrown- Returns:
obj
if notnull
- Throws:
NullPointerException
- ifobj
isnull
-
filterNull
@NonNull public static <T> Stream<T> filterNull(T item)
A filter used to remove null items from a stream.- Type Parameters:
T
- the item type- Parameters:
item
- the item to filter- Returns:
- the item as a steam or an empty stream if the item is
null
-
asNullableType
public static <T> T asNullableType(Object obj)
-
-