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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.
-
Constructor Details
-
ObjectsUtil
public ObjectsUtil()
-
-
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
-
returnRequireNonNull
@Nonnull public static <T> T returnRequireNonNull(@Nonnull T object) 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
@Nonnull public static <T> T[] paramSizeNonZero(@Nonnull T[] objects) 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
-