Class ObjectsUtil
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIs an abstract exception class.static classDesignates element non-empty is required.static classDesignates element non-null is required.static classDesignates elements value non-duplicated required.static classDesignates non-empty is required.static classDesignates non-null is required.static classDesignates size non-zero is required. -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]requireElementNonEmpty(String[] strings) Validates elements of an array is notnulland throwsRequireElementNonEmptyExceptionif the argument value does not match the condition.static Collection<String> requireElementNonEmpty(Collection<String> collection) Validates elements of a collection is notnulland throwsRequireElementNonEmptyExceptionif the argument value does not match the condition.static <T> Collection<T> requireElementNonNull(Collection<T> collection) Validates elements of a collection is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.static <T> T[]requireElementNonNull(T[] objects) Validates elements of an array is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.static <T> Collection<T> requireElementsNonDuplicated(Collection<T> collection) Validates elements of a collection is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.static <T> T[]requireElementsNonDuplicated(T[] objects) Validates elements of an array is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.static StringrequireNonEmpty(String string) Validates the argument is notnullorblank("")and throwsRequireNonEmptyExceptionif the argument value does not match the condition.static voidrequireNonEmpty(String string1, String string2, String... strings) Validates multiple arguments are notnullorblank("")and throwsRequireNonEmptyExceptionif arguments value do not match the condition.static voidrequireNonNull(Object object1, Object object2, Object... objects) Validates multiple arguments are notnulland throwsRequireNonNullExceptionif arguments value do not match the condition.static <T> TrequireNonNull(T object) Validates the argument is notnulland throwsRequireNonNullExceptionif the argument value does not match the condition.static <T> Collection<T> requireSizeNonZero(Collection<T> collection) Validates the length of a collection is not zero and throwsRequireSizeNonZeroExceptionif the argument value does not match the condition.static <T> T[]requireSizeNonZero(T[] objects) Validates the length of an array is not zero and throwsRequireSizeNonZeroExceptionif the argument value does not match the condition.
-
Method Details
-
requireNonNull
Validates the argument is notnulland throwsRequireNonNullExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument- Parameters:
object- Any object- Returns:
- the argument
-
requireNonNull
@Nonnull public static void requireNonNull(@RequireNonnull Object object1, @RequireNonnull Object object2, @RequireNonnull Object... objects) Validates multiple arguments are notnulland throwsRequireNonNullExceptionif arguments value do not match the condition.This is used to validate multiple arguments at one time.
- Parameters:
object1- Any objectobject2- Any objectobjects- Any objects
-
requireNonEmpty
Validates the argument is notnullorblank("")and throwsRequireNonEmptyExceptionif the argument value does not match the condition.- Parameters:
string- Any string- Returns:
- the argument
-
requireNonEmpty
@Nonnull public static void requireNonEmpty(@RequireNonempty String string1, @RequireNonempty String string2, @RequireNonempty String... strings) Validates multiple arguments are notnullorblank("")and throwsRequireNonEmptyExceptionif arguments value do not match the condition.- Parameters:
string1- Any stringstring2- Any stringstrings- Any strings
-
requireSizeNonZero
Validates the length of an array is not zero and throwsRequireSizeNonZeroExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument array- Parameters:
objects- Any object,nullis acceptable.- Returns:
- the argument
-
requireSizeNonZero
@Nonnull public static <T> Collection<T> requireSizeNonZero(@RequireSizeNonzero Collection<T> collection) Validates the length of a collection is not zero and throwsRequireSizeNonZeroExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument collection- Parameters:
collection- Any collection,nullis acceptable.- Returns:
- the argument
-
requireElementNonNull
Validates elements of an array is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument array- Parameters:
objects- Any object,nullis acceptable.- Returns:
- the argument
-
requireElementNonNull
@Nonnull public static <T> Collection<T> requireElementNonNull(@RequireElementNonnull Collection<T> collection) Validates elements of a collection is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument collection- Parameters:
collection- Any collection,nullis acceptable.- Returns:
- the argument
-
requireElementNonEmpty
Validates elements of an array is notnulland throwsRequireElementNonEmptyExceptionif the argument value does not match the condition.- Parameters:
strings- Any strings,nullis acceptable.- Returns:
- the argument
-
requireElementNonEmpty
@Nonnull public static Collection<String> requireElementNonEmpty(@RequireElementNonempty Collection<String> collection) Validates elements of a collection is notnulland throwsRequireElementNonEmptyExceptionif the argument value does not match the condition.- Parameters:
collection- Any collection,nullis acceptable.- Returns:
- the argument
-
requireElementsNonDuplicated
Validates elements of an array is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument array- Parameters:
objects- Any object,nullis acceptable.- Returns:
- the argument
-
requireElementsNonDuplicated
@Nonnull public static <T> Collection<T> requireElementsNonDuplicated(@RequireElementNonnull Collection<T> collection) Validates elements of a collection is notnulland throwsRequireElementNonNullExceptionif the argument value does not match the condition.- Type Parameters:
T- The class of the argument collection- Parameters:
collection- Any collection,nullis acceptable.- Returns:
- the argument
-