- java.lang.Object
-
- life.expert.common.base.Preconditions
-
public final class Preconditions extends java.lang.Object- methods for checking strings and collections (the presence of an element in the collection, the emptiness of elements, etc.) as well as advanced logging methods display indices of empty elements, etc. - contain categories of side effects: assert (raise assertion),checkArgument (raise illegal argument exception),checkState (raise illegal state exception)
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Predicate<? extends java.util.Collection<?>>badCollectionThe constant badCollection.static java.util.function.LongPredicatebadLongThe constant badLong.static java.util.function.Predicate<? extends java.util.Map<?,?>>badMapThe constant badMap.static java.util.function.Predicate<java.lang.String>badStringThe constant badString.static java.util.function.Predicate<? extends java.util.Collection<?>>goodCollectionThe constant goodCollection.static java.util.function.LongPredicategoodLongThe constant goodLong.static java.util.function.Predicate<? extends java.util.Map<?,?>>goodMapThe constant goodMap.static java.util.function.Predicate<java.lang.String>goodStringThe constant goodString.
-
Constructor Summary
Constructors Constructor Description Preconditions()
-
Method Summary
Modifier and Type Method Description static <E> @NotNull java.util.function.Predicate<? super java.util.Collection<E>>anyMatchInCollection(@Nullable java.util.function.Predicate<E> p)None match in collection predicate.static <EKey,EValue>
@NotNull java.util.function.Predicate<? super java.util.Map<EKey,EValue>>anyMatchInMap(@Nullable java.util.function.Predicate<EValue> p)None match in map predicate.static voidassertArgument(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argumentstatic longassertArgument(long number)Check argument, lazy message.static longassertArgument(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)Check argument, message.static longassertArgument(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static <E extends java.util.Collection<?>>
EassertArgument(E collection)Check argument, lazy message.static <E> EassertArgument(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)Check argument, message.static <E> EassertArgument(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static java.lang.StringassertArgument(java.lang.String string)Check argument, lazy message.static <TKey,TValue>
java.util.Map<TKey,TValue>assertArgument(java.util.Map<TKey,TValue> map)Check argument, lazy message.static <TKey,TValue>
java.util.Map<TKey,TValue>assertArgument(java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> invalidValue)Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) Usually this method for check input args in private methods for raise assertion instead exception.static <T extends java.util.Collection<E>,E>
TassertArgument(T collection, @Nullable java.util.function.Predicate<E> invalidElement)Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) Usually this method for check input args in private methods for raise assertion instead exception.static <E> EassertArgumentNotNull(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument not null e.static voidcheckArgument(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static longcheckArgument(long number)Check argument, lazy message.static longcheckArgument(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)Check argument, message.static longcheckArgument(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static <E extends java.util.Collection<?>>
EcheckArgument(E collection)Check argument, lazy message.static <E> EcheckArgument(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)Check argument, message.static <E> EcheckArgument(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static java.lang.StringcheckArgument(java.lang.String string)Check argument, lazy message.static <E> java.util.Collection<E>checkArgument(java.util.Collection<E> collection, @Nullable java.util.function.Predicate<E> invalidElement)Helper method for checking input args of collection type or constructor in immutable colls Checking every element in collection with Predicate (usual test for nullable or empty elements) If you need simply test collection for empty elements use Apache utils's Validate.notEmpty method instead For example, you can use the method (which raise IllegalArgumentException) - inside constructors of immutable objects - inside methods for testing inputs argumentsstatic <EKey,EValue>
java.util.Map<EKey,EValue>checkArgument(java.util.Map<EKey,EValue> map, @Nullable java.util.function.Predicate<EValue> invalidValue)Helper method for checking input args of map type or constructor in immutable colls Checking every element in map with Predicate (usual test for nullable or empty entries values) If you need simply test map for empty elements use Apache utils's Validate.notEmpty method instead For example, you can use the method (which raise IllegalArgumentException) - inside constructors of immutable objects - inside methods for testing inputs argumentsstatic <TKey,TValue>
java.util.Map<TKey,TValue>checkArgument(java.util.Map<TKey,TValue> map)Check argument, lazy message.static <E> EcheckArgumentNotNull(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument not null e.static voidcheckState(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check state, lazy message.static longcheckState(long number)Check state, lazy message.static longcheckState(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)Check argument, message.static longcheckState(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static <E extends java.util.Collection<?>>
EcheckState(E collection)Check state, lazy message.static <E> EcheckState(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)Check argument, message.static <E> EcheckState(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.static java.lang.StringcheckState(java.lang.String string)Check state, lazy message.static <TKey,TValue>
java.util.Map<TKey,TValue>checkState(java.util.Map<TKey,TValue> map)Check state, lazy message.static <TKey,TValue>
java.util.Map<TKey,TValue>checkState(java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> invalidValue)Helper method for use in mutable objects if you want to check some object property before method work Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) For example, you can use the method (which raise IllegalStateException) - inside methods of mutable objects for checking object's state before executionstatic <T extends java.util.Collection<E>,E>
TcheckState(T collection, @Nullable java.util.function.Predicate<E> invalidElement)Helper method for use in mutable objects if you want to check some object property before method work Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) For example, you can use the method (which raise IllegalStateException) - inside methods of mutable objects for checking object's state before executionstatic <E> EcheckStateNotNull(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check state not null e.static <E> @org.jetbrains.annotations.NotNull longgetCountOfObjectsInCollection(@Nullable java.util.Collection<E> collection, @Nullable java.util.function.Predicate<E> filter)helper method: numeric of found object in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods.static <TKey,TValue>
@org.jetbrains.annotations.NotNull longgetCountOfObjectsInMap(@Nullable java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> filterValues)helper method: numeric of found object in map Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods.static <E> @NotNull java.lang.StringgetIndexesOfObjectsInCollection(@Nullable java.util.Collection<E> collection, @Nullable java.util.function.Predicate<E> filter)helper method: get comma separated string with indexes of found objects in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods (and also in checkCollection, checkCollectionRaiseIllegalStateException, checkCollectionRaiseAssertion).static <E> @NotNull java.lang.StringgetIndexesOfObjectsInCollectionForLog(@Nullable java.util.Collection<E> collection, @Nullable java.util.function.Predicate<E> filter)helper method: get comma separated string with FIRST 80 indexes of found objects in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods (and also in checkCollection, checkCollectionRaiseIllegalStateException, checkCollectionRaiseAssertion).static <TKey,TValue>
@NotNull java.lang.StringgetKeysOfObjectsInMap(@Nullable java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> filterValues)helper method: get comma separated string with indexes of found objects in collection Name analogicaly getIndexesOfObjectsInCollection Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods (and also in checkMap, checkMapRaiseIllegalStateException, checkMapRaiseAssertion).static <TKey,TValue>
@NotNull java.lang.StringgetKeysOfObjectsInMapForLog(@Nullable java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> filterValues)helper method: get comma separated string with FIRST 80 indexes of found objects in collection Name analogicaly getIndexesOfObjectsInCollection Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods (and also in checkMap, checkMapRaiseIllegalStateException, checkMapRaiseAssertion).static booleanisCheckArgument(long number)Check argument, lazy message.static booleanisCheckArgument(long argument, @Nullable java.util.function.LongPredicate wrong)Check argument, message.static <E> booleanisCheckArgument(E argument, @Nullable java.util.function.Predicate<E> wrong)Check argument, message.static booleanisCheckArgument(java.lang.String string)Check argument, lazy message.static booleanisCheckArgument(java.util.Collection<?> collection)Check argument, lazy message.static <E> booleanisCheckArgument(java.util.Collection<E> collection, @Nullable java.util.function.Predicate<E> invalidElement)Helper method for strategy "return Optional instead Exception" Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) For example, you can use the method (if you need return optional in your method instead raise exception) - inside methods for testing inputs arguments - inside methods of mutable objects for checking object's state before executionstatic booleanisCheckArgument(java.util.Map<?,?> map)Check argument, lazy message.static <TKey,TValue>
booleanisCheckArgument(java.util.Map<TKey,TValue> map, @Nullable java.util.function.Predicate<TValue> invalidValue)Helper method for strategy "return Optional instead Exception" Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) For example, you can use the method (if you need return optional in your method instead raise exception) - inside methods for testing inputs arguments - inside methods of mutable objects for checking object's state before executionstatic <E> @NotNull java.util.function.Predicate<? super java.util.Collection<E>>noneMatchInCollection(@Nullable java.util.function.Predicate<E> p)None match in collection predicate.static <EKey,EValue>
@NotNull java.util.function.Predicate<? super java.util.Map<EKey,EValue>>noneMatchInMap(@Nullable java.util.function.Predicate<EValue> p)None match in map predicate.
-
-
-
Field Detail
-
goodLong
public static final java.util.function.LongPredicate goodLong
The constant goodLong.
-
badLong
public static final java.util.function.LongPredicate badLong
The constant badLong.
-
goodString
public static final java.util.function.Predicate<java.lang.String> goodString
The constant goodString.
-
badString
public static final java.util.function.Predicate<java.lang.String> badString
The constant badString.
-
goodCollection
public static final java.util.function.Predicate<? extends java.util.Collection<?>> goodCollection
The constant goodCollection.
-
badCollection
public static final java.util.function.Predicate<? extends java.util.Collection<?>> badCollection
The constant badCollection.
-
goodMap
public static final java.util.function.Predicate<? extends java.util.Map<?,?>> goodMap
The constant goodMap.
-
badMap
public static final java.util.function.Predicate<? extends java.util.Map<?,?>> badMap
The constant badMap.
-
-
Method Detail
-
anyMatchInCollection
@NotNull public static final <E> @NotNull java.util.function.Predicate<? super java.util.Collection<E>> anyMatchInCollection(@Nullable @Nullable java.util.function.Predicate<E> p)None match in collection predicate.- Type Parameters:
E- the type parameter- Parameters:
p- the p- Returns:
- the predicate
-
anyMatchInMap
@NotNull public static final <EKey,EValue> @NotNull java.util.function.Predicate<? super java.util.Map<EKey,EValue>> anyMatchInMap(@Nullable @Nullable java.util.function.Predicate<EValue> p)None match in map predicate.- Type Parameters:
EKey- the type parameterEValue- the type parameter- Parameters:
p- the p- Returns:
- the predicate
-
noneMatchInCollection
@NotNull public static final <E> @NotNull java.util.function.Predicate<? super java.util.Collection<E>> noneMatchInCollection(@Nullable @Nullable java.util.function.Predicate<E> p)None match in collection predicate.- Type Parameters:
E- the type parameter- Parameters:
p- the p- Returns:
- the predicate
-
noneMatchInMap
@NotNull public static final <EKey,EValue> @NotNull java.util.function.Predicate<? super java.util.Map<EKey,EValue>> noneMatchInMap(@Nullable @Nullable java.util.function.Predicate<EValue> p)None match in map predicate.- Type Parameters:
EKey- the type parameterEValue- the type parameter- Parameters:
p- the p- Returns:
- the predicate
-
isCheckArgument
public static <E> boolean isCheckArgument(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong)Check argument, message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that not- Returns:
- the e
-
checkArgument
public static <E> E checkArgument(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkArgument
public static <E> E checkArgument(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkState
public static <E> E checkState(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkState
public static <E> E checkState(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
assertArgument
public static <E> E assertArgument(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
assertArgument
public static <E> E assertArgument(E argument, @Nullable @Nullable java.util.function.Predicate<E> wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkArgument
public static void checkArgument(boolean expression, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Parameters:
expression- the expressionerrorMessage- the error message
-
checkState
public static void checkState(boolean expression, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check state, lazy message.- Parameters:
expression- the expressionerrorMessage- the error message
-
assertArgument
public static void assertArgument(boolean expression, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument- Parameters:
expression- the expressionerrorMessage- the error message
-
checkArgumentNotNull
public static <E> E checkArgumentNotNull(E argument, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument not null e.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumenterrorMessage- the error message- Returns:
- the e
-
checkStateNotNull
public static <E> E checkStateNotNull(E argument, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check state not null e.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumenterrorMessage- the error message- Returns:
- the e
-
assertArgumentNotNull
public static <E> E assertArgumentNotNull(E argument, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument not null e.- Type Parameters:
E- the type parameter- Parameters:
argument- the argumenterrorMessage- the error message- Returns:
- the e
-
checkArgument
public static <E> java.util.Collection<E> checkArgument(java.util.Collection<E> collection, @Nullable @Nullable java.util.function.Predicate<E> invalidElement)Helper method for checking input args of collection type or constructor in immutable colls Checking every element in collection with Predicate (usual test for nullable or empty elements) If you need simply test collection for empty elements use Apache utils's Validate.notEmpty method instead For example, you can use the method (which raise IllegalArgumentException) - inside constructors of immutable objects - inside methods for testing inputs argumentscheckCollection(c,String::isBlank); checkCollection(c,Objects::isNull);************************- Type Parameters:
E- the type parameter- Parameters:
collection- the collectioninvalidElement- the filter- Returns:
- the t
- Throws:
java.lang.NullPointerException- if argument nullablejava.lang.IllegalArgumentException- if argument empty (or if one collection's element is empty)
-
checkArgument
public static <EKey,EValue> java.util.Map<EKey,EValue> checkArgument(java.util.Map<EKey,EValue> map, @Nullable @Nullable java.util.function.Predicate<EValue> invalidValue)Helper method for checking input args of map type or constructor in immutable colls Checking every element in map with Predicate (usual test for nullable or empty entries values) If you need simply test map for empty elements use Apache utils's Validate.notEmpty method instead For example, you can use the method (which raise IllegalArgumentException) - inside constructors of immutable objects - inside methods for testing inputs argumentscheckMap(m,String::isBlank); checkMap(m,Objects::isNull);************************- Type Parameters:
EKey- the type parameterEValue- the type parameter- Parameters:
map- the mapinvalidValue- the filter- Returns:
- the map
- Throws:
java.lang.NullPointerException- if argument nullablejava.lang.IllegalArgumentException- if argument empty (or if one map's element is empty)
-
isCheckArgument
public static <E> boolean isCheckArgument(java.util.Collection<E> collection, @Nullable @Nullable java.util.function.Predicate<E> invalidElement)Helper method for strategy "return Optional instead Exception" Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) For example, you can use the method (if you need return optional in your method instead raise exception) - inside methods for testing inputs arguments - inside methods of mutable objects for checking object's state before executionif ( checkCollectionIsEmpty(c,String::isBlank) ) return Optional.empty(); if ( checkCollectionIsEmpty(c,Objects::isNull) ) return Optional.empty();************************- Type Parameters:
E- the type parameter- Parameters:
collection- the collectioninvalidElement- the filter- Returns:
- the boolean
- Throws:
java.lang.NullPointerException- if argument nullable
-
isCheckArgument
public static <TKey,TValue> boolean isCheckArgument(java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> invalidValue)Helper method for strategy "return Optional instead Exception" Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) For example, you can use the method (if you need return optional in your method instead raise exception) - inside methods for testing inputs arguments - inside methods of mutable objects for checking object's state before executionif ( checkMapIsEmpty(m,String::isBlank) ) return Optional.empty(); if ( checkMapIsEmpty(m,Objects::isNull) ) return Optional.empty();************************- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the mapinvalidValue- the filter- Returns:
- the boolean
- Throws:
java.lang.NullPointerException- if argument nullable
-
checkState
public static <T extends java.util.Collection<E>,E> T checkState(T collection, @Nullable @Nullable java.util.function.Predicate<E> invalidElement)Helper method for use in mutable objects if you want to check some object property before method work Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) For example, you can use the method (which raise IllegalStateException) - inside methods of mutable objects for checking object's state before executioncheckCollectionRaiseIllegalStateException(c,String::isBlank); checkCollectionRaiseIllegalStateException(c,Objects::isNull);************************- Type Parameters:
T- the type parameterE- the type parameter- Parameters:
collection- the collectioninvalidElement- the filter- Returns:
- the t
- Throws:
java.lang.IllegalStateException- if argument nullablejava.lang.IllegalStateException- if argument empty (or if one collection's element is empty)
-
checkState
public static <TKey,TValue> java.util.Map<TKey,TValue> checkState(java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> invalidValue)Helper method for use in mutable objects if you want to check some object property before method work Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) For example, you can use the method (which raise IllegalStateException) - inside methods of mutable objects for checking object's state before executioncheckMapRaiseIllegalStateException(c,String::isBlank); checkMapRaiseIllegalStateException(c,Objects::isNull);************************- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the mapinvalidValue- the filter- Returns:
- the map
- Throws:
java.lang.IllegalStateException- if argument nullablejava.lang.IllegalStateException- if argument empty (or if one map's element is empty)
-
assertArgument
public static <T extends java.util.Collection<E>,E> T assertArgument(T collection, @Nullable @Nullable java.util.function.Predicate<E> invalidElement)Check argument of type Collection Checking every element in collection with Predicate (usual test for nullable or empty elements) Usually this method for check input args in private methods for raise assertion instead exception.checkCollectionRaiseAssertion(c,String::isBlank); checkCollectionRaiseAssertion(c,Objects::isNull);************************- Type Parameters:
T- the type parameterE- the type parameter- Parameters:
collection- the collectioninvalidElement- the filter- Returns:
- the t
- Throws:
java.lang.AssertionError- if any match
-
assertArgument
public static <TKey,TValue> java.util.Map<TKey,TValue> assertArgument(java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> invalidValue)Check argument of type Map Checking every element in map with Predicate (usual test for nullable or empty entries values) Usually this method for check input args in private methods for raise assertion instead exception.checkMapRaiseAssertion(c,String::isBlank); checkMapRaiseAssertion(c,Objects::isNull);************************- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the mapinvalidValue- the filter- Returns:
- the map
- Throws:
java.lang.AssertionError- if any match
-
checkArgument
public static <E extends java.util.Collection<?>> E checkArgument(E collection)
Check argument, lazy message.- Type Parameters:
E- the type parameter- Parameters:
collection- the collection- Returns:
- the e
-
isCheckArgument
public static boolean isCheckArgument(java.util.Collection<?> collection)
Check argument, lazy message.- Parameters:
collection- the collection- Returns:
- the e
-
checkState
public static <E extends java.util.Collection<?>> E checkState(E collection)
Check state, lazy message.- Type Parameters:
E- the type parameter- Parameters:
collection- the collection- Returns:
- the e
-
assertArgument
public static <E extends java.util.Collection<?>> E assertArgument(E collection)
Check argument, lazy message.- Type Parameters:
E- the type parameter- Parameters:
collection- the collection- Returns:
- the string
-
checkArgument
public static <TKey,TValue> java.util.Map<TKey,TValue> checkArgument(java.util.Map<TKey,TValue> map)
Check argument, lazy message.- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the map- Returns:
- the e
-
isCheckArgument
public static boolean isCheckArgument(java.util.Map<?,?> map)
Check argument, lazy message.- Parameters:
map- the map- Returns:
- the e
-
checkState
public static <TKey,TValue> java.util.Map<TKey,TValue> checkState(java.util.Map<TKey,TValue> map)
Check state, lazy message.- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the map- Returns:
- the e
-
assertArgument
public static <TKey,TValue> java.util.Map<TKey,TValue> assertArgument(java.util.Map<TKey,TValue> map)
Check argument, lazy message.- Type Parameters:
TKey- the type parameterTValue- the type parameter- Parameters:
map- the map- Returns:
- the string
-
checkArgument
public static java.lang.String checkArgument(java.lang.String string)
Check argument, lazy message.- Parameters:
string- the string- Returns:
- the string
-
isCheckArgument
public static boolean isCheckArgument(java.lang.String string)
Check argument, lazy message.- Parameters:
string- the string- Returns:
- the string
-
checkState
public static java.lang.String checkState(java.lang.String string)
Check state, lazy message.- Parameters:
string- the string- Returns:
- the string
-
assertArgument
public static java.lang.String assertArgument(java.lang.String string)
Check argument, lazy message.- Parameters:
string- the string- Returns:
- the string
-
isCheckArgument
public static boolean isCheckArgument(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong)Check argument, message.- Parameters:
argument- the argumentwrong- the that not- Returns:
- the e
-
checkArgument
public static long checkArgument(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkArgument
public static long checkArgument(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkState
public static long checkState(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkState
public static long checkState(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
assertArgument
public static long assertArgument(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.lang.String errorMessage)Check argument, message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
assertArgument
public static long assertArgument(long argument, @Nullable @Nullable java.util.function.LongPredicate wrong, @Nullable @Nullable java.util.function.Supplier<java.lang.String> errorMessage)Check argument, lazy message.- Parameters:
argument- the argumentwrong- the that noterrorMessage- the error message- Returns:
- the e
-
checkArgument
public static long checkArgument(long number)
Check argument, lazy message.- Parameters:
number- the string- Returns:
- the string
-
isCheckArgument
public static boolean isCheckArgument(long number)
Check argument, lazy message.- Parameters:
number- the string- Returns:
- the string
-
checkState
public static long checkState(long number)
Check state, lazy message.- Parameters:
number- the string- Returns:
- the string
-
assertArgument
public static long assertArgument(long number)
Check argument, lazy message.- Parameters:
number- the string- Returns:
- the string
-
getIndexesOfObjectsInCollection
@NotNull public static <E> @NotNull java.lang.String getIndexesOfObjectsInCollection(@Nullable @Nullable java.util.Collection<E> collection, @Nullable @Nullable java.util.function.Predicate<E> filter)helper method: get comma separated string with indexes of found objects in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods (and also in checkCollection, checkCollectionRaiseIllegalStateException, checkCollectionRaiseAssertion).throw new IllegalArgumentException( String.format( "Every element of collection should not be null or empty: %s \n Indexes of wrong elements: %s " , collection , getIndexesOfObjectsInCollection( collection , filter ) ) );************************- Type Parameters:
E- the type of desired object- Parameters:
collection- collection in which we will look forfilter- condition for find the desired object- Returns:
- comma separated string with indexes of found object in collection return "" if collection or predicate is null, or collection is empty
-
getIndexesOfObjectsInCollectionForLog
@NotNull public static <E> @NotNull java.lang.String getIndexesOfObjectsInCollectionForLog(@Nullable @Nullable java.util.Collection<E> collection, @Nullable @Nullable java.util.function.Predicate<E> filter)helper method: get comma separated string with FIRST 80 indexes of found objects in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods (and also in checkCollection, checkCollectionRaiseIllegalStateException, checkCollectionRaiseAssertion).throw new IllegalArgumentException( String.format( "Every element of collection should not be null or empty: %s \n Indexes of wrong elements: %s " , collection , getIndexesOfObjectsInCollection( collection , filter ) ) );************************- Type Parameters:
E- the type of desired object- Parameters:
collection- collection in which we will look forfilter- condition for find the desired object- Returns:
- comma separated string with indexes of found object in collection return "" if collection or predicate is null, or collection is empty
-
getKeysOfObjectsInMap
@NotNull public static <TKey,TValue> @NotNull java.lang.String getKeysOfObjectsInMap(@Nullable @Nullable java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> filterValues)helper method: get comma separated string with indexes of found objects in collection Name analogicaly getIndexesOfObjectsInCollection Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods (and also in checkMap, checkMapRaiseIllegalStateException, checkMapRaiseAssertion).throw new IllegalArgumentException( String.format( "Every element of map should not be null or empty: %s \n Indexes of wrong elements: %s " , map , getKeysOfObjectsInMap( map , filter ) ) );************************- Type Parameters:
TKey- the type of keys in mapTValue- the type of values in map- Parameters:
map- map in which we will look forfilterValues- condition for find the desired object- Returns:
- comma separated string with keys of found entrie's values in map return "" if map or predicate is null, or map is empty
-
getKeysOfObjectsInMapForLog
@NotNull public static <TKey,TValue> @NotNull java.lang.String getKeysOfObjectsInMapForLog(@Nullable @Nullable java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> filterValues)helper method: get comma separated string with FIRST 80 indexes of found objects in collection Name analogicaly getIndexesOfObjectsInCollection Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods (and also in checkMap, checkMapRaiseIllegalStateException, checkMapRaiseAssertion).throw new IllegalArgumentException( String.format( "Every element of map should not be null or empty: %s \n Indexes of wrong elements: %s " , map , getKeysOfObjectsInMap( map , filter ) ) );************************- Type Parameters:
TKey- the type of keys in mapTValue- the type of values in map- Parameters:
map- map in which we will look forfilterValues- condition for find the desired object- Returns:
- comma separated string with keys of found entrie's values in map return "" if map or predicate is null, or map is empty
-
getCountOfObjectsInCollection
@NotNull public static <E> @org.jetbrains.annotations.NotNull long getCountOfObjectsInCollection(@Nullable @Nullable java.util.Collection<E> collection, @Nullable @Nullable java.util.function.Predicate<E> filter)helper method: numeric of found object in collection Method checks every element in collection with Predicate (usual test for nullable or empty elements) You can use the method in log methods.************************- Type Parameters:
E- the type of desired object- Parameters:
collection- collection in which we will look forfilter- condition for find the desired object- Returns:
- numeric of found objects in collection return 0 if collection or predicate is null, or collection is empty
-
getCountOfObjectsInMap
@NotNull public static <TKey,TValue> @org.jetbrains.annotations.NotNull long getCountOfObjectsInMap(@Nullable @Nullable java.util.Map<TKey,TValue> map, @Nullable @Nullable java.util.function.Predicate<TValue> filterValues)helper method: numeric of found object in map Method checks every element in map with Predicate (usual test for nullable or empty entries values) You can use the method in log methods.************************- Type Parameters:
TKey- the type of keys in mapTValue- the type of values in map- Parameters:
map- Map in which we will look forfilterValues- condition for find the desired object- Returns:
- numeric of found objects in map (using filter by values) return 0 if map or predicate is null, or map is empty
-
-