java.lang.Object
jp.ecuacion.lib.core.util.ObjectsUtil
Provides utility methods for
Objects.requireNonnull and other checks.
Objects.requireNonnull throws NullPointerException and we can't see the difference
whether it happens because of the parameter or return value check, or other reasons.
By using these methods you can see it by additional messages.
Several other methods provided to clarify an exception is thrown from ecuacion apps.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidparamRequireNonNull(Object object1, Object object2, Object... objects) Validates multiple arguments are notnulland throwsNullPointerExceptionifnull.static <T> TparamRequireNonNull(T object) Validates the argument is notnulland throwsNullPointerExceptionifnull.static <T> Collection<T> paramSizeNonZero(Collection<T> colleciton) Validates the size of the para collection is not zero and throwsIllegalArgumentExceptionif zero.static <T> T[]paramSizeNonZero(T[] objects) Validates the length of the param array is not zero and throwsIllegalArgumentExceptionif zero.static <T> TrequireNonNull(T object) Validates the variable is notnulland throwsNullPointerExceptionifnull.static <T> TreturnRequireNonNull(T object) Validates the return value is notnulland throwsNullPointerExceptionifnull.
-
Method Details
-
paramRequireNonNull
Validates the argument is notnulland throwsNullPointerExceptionifnull.This is used for arguments of the method or constructor parameters as you can see it from the name of the method.
- Type Parameters:
T- The class of the argument- Parameters:
object- Any object- Returns:
- the argument
-
paramRequireNonNull
@Nonnull public static void paramRequireNonNull(@RequireNonnull Object object1, @RequireNonnull Object object2, @RequireNonnull Object... objects) Validates multiple arguments are notnulland throwsNullPointerExceptionifnull.This is used to validate multiple arguments at one time.
- Parameters:
object1- Any objectobject2- Any objectobjects- Any objects
-
returnRequireNonNull
Validates the return value is notnulland throwsNullPointerExceptionifnull.This is used for return values of the method or constructor parameters as you can see it from the name of the method.
- Type Parameters:
T- The class of the argument- Parameters:
object- Any object- Returns:
- the argument
-
requireNonNull
Validates the variable is notnulland throwsNullPointerExceptionifnull.- Type Parameters:
T- The class of the argument- Parameters:
object- Any object- Returns:
- the argument
-
paramSizeNonZero
Validates the length of the param array is not zero and throwsIllegalArgumentExceptionif zero.- Type Parameters:
T- The class of the argument array- Parameters:
objects- Any object- Returns:
- the argument
-
paramSizeNonZero
Validates the size of the para collection is not zero and throwsIllegalArgumentExceptionif zero.- Type Parameters:
T- The class of the argument collection- Parameters:
colleciton- Any colleciton- Returns:
- the argument
-