Module life.expert

Class 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<?>> badCollection
      The constant badCollection.
      static java.util.function.LongPredicate badLong
      The constant badLong.
      static java.util.function.Predicate<? extends java.util.Map<?,​?>> badMap
      The constant badMap.
      static java.util.function.Predicate<java.lang.String> badString
      The constant badString.
      static java.util.function.Predicate<? extends java.util.Collection<?>> goodCollection
      The constant goodCollection.
      static java.util.function.LongPredicate goodLong
      The constant goodLong.
      static java.util.function.Predicate<? extends java.util.Map<?,​?>> goodMap
      The constant goodMap.
      static java.util.function.Predicate<java.lang.String> goodString
      The 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 void assertArgument​(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check argument
      static long assertArgument​(long number)
      Check argument, lazy message.
      static long assertArgument​(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static long assertArgument​(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<?>>
      E
      assertArgument​(E collection)
      Check argument, lazy message.
      static <E> E assertArgument​(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static <E> E assertArgument​(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.String assertArgument​(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>
      T
      assertArgument​(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> E assertArgumentNotNull​(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check argument not null e.
      static void checkArgument​(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check argument, lazy message.
      static long checkArgument​(long number)
      Check argument, lazy message.
      static long checkArgument​(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static long checkArgument​(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<?>>
      E
      checkArgument​(E collection)
      Check argument, lazy message.
      static <E> E checkArgument​(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static <E> E checkArgument​(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.String checkArgument​(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 arguments
      static <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 arguments
      static <TKey,​TValue>
      java.util.Map<TKey,​TValue>
      checkArgument​(java.util.Map<TKey,​TValue> map)
      Check argument, lazy message.
      static <E> E checkArgumentNotNull​(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check argument not null e.
      static void checkState​(boolean expression, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check state, lazy message.
      static long checkState​(long number)
      Check state, lazy message.
      static long checkState​(long argument, @Nullable java.util.function.LongPredicate wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static long checkState​(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<?>>
      E
      checkState​(E collection)
      Check state, lazy message.
      static <E> E checkState​(E argument, @Nullable java.util.function.Predicate<E> wrong, @Nullable java.lang.String errorMessage)
      Check argument, message.
      static <E> E checkState​(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.String checkState​(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 execution
      static <T extends java.util.Collection<E>,​E>
      T
      checkState​(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 execution
      static <E> E checkStateNotNull​(E argument, @Nullable java.util.function.Supplier<java.lang.String> errorMessage)
      Check state not null e.
      static <E> @org.jetbrains.annotations.NotNull long getCountOfObjectsInCollection​(@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 long
      getCountOfObjectsInMap​(@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.String getIndexesOfObjectsInCollection​(@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.String getIndexesOfObjectsInCollectionForLog​(@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.String
      getKeysOfObjectsInMap​(@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.String
      getKeysOfObjectsInMapForLog​(@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 boolean isCheckArgument​(long number)
      Check argument, lazy message.
      static boolean isCheckArgument​(long argument, @Nullable java.util.function.LongPredicate wrong)
      Check argument, message.
      static <E> boolean isCheckArgument​(E argument, @Nullable java.util.function.Predicate<E> wrong)
      Check argument, message.
      static boolean isCheckArgument​(java.lang.String string)
      Check argument, lazy message.
      static boolean isCheckArgument​(java.util.Collection<?> collection)
      Check argument, lazy message.
      static <E> boolean isCheckArgument​(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 execution
      static boolean isCheckArgument​(java.util.Map<?,​?> map)
      Check argument, lazy message.
      static <TKey,​TValue>
      boolean
      isCheckArgument​(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 execution
      static <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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
    • Constructor Detail

      • Preconditions

        public Preconditions()
    • 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 parameter
        EValue - 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 parameter
        EValue - 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 argument
        wrong - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 expression
        errorMessage - 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 expression
        errorMessage - 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 expression
        errorMessage - 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 argument
        errorMessage - 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 argument
        errorMessage - 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 argument
        errorMessage - 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 arguments
        
              checkCollection(c,String::isBlank);
              checkCollection(c,Objects::isNull);
         ************************
        Type Parameters:
        E - the type parameter
        Parameters:
        collection - the collection
        invalidElement - the filter
        Returns:
        the t
        Throws:
        java.lang.NullPointerException - if argument nullable
        java.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 arguments
        
              checkMap(m,String::isBlank);
              checkMap(m,Objects::isNull);
         ************************
        Type Parameters:
        EKey - the type parameter
        EValue - the type parameter
        Parameters:
        map - the map
        invalidValue - the filter
        Returns:
        the map
        Throws:
        java.lang.NullPointerException - if argument nullable
        java.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 execution
        
              if ( checkCollectionIsEmpty(c,String::isBlank) )
                      return Optional.empty();
        
        
              if ( checkCollectionIsEmpty(c,Objects::isNull) )
                      return Optional.empty();
         ************************
        Type Parameters:
        E - the type parameter
        Parameters:
        collection - the collection
        invalidElement - 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 execution
        
              if ( checkMapIsEmpty(m,String::isBlank) )
                      return Optional.empty();
        
        
              if ( checkMapIsEmpty(m,Objects::isNull) )
                      return Optional.empty();
         ************************
        Type Parameters:
        TKey - the type parameter
        TValue - the type parameter
        Parameters:
        map - the map
        invalidValue - 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 execution
        
              checkCollectionRaiseIllegalStateException(c,String::isBlank);
              checkCollectionRaiseIllegalStateException(c,Objects::isNull);
         ************************
        Type Parameters:
        T - the type parameter
        E - the type parameter
        Parameters:
        collection - the collection
        invalidElement - the filter
        Returns:
        the t
        Throws:
        java.lang.IllegalStateException - if argument nullable
        java.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 execution
        
              checkMapRaiseIllegalStateException(c,String::isBlank);
              checkMapRaiseIllegalStateException(c,Objects::isNull);
         ************************
        Type Parameters:
        TKey - the type parameter
        TValue - the type parameter
        Parameters:
        map - the map
        invalidValue - the filter
        Returns:
        the map
        Throws:
        java.lang.IllegalStateException - if argument nullable
        java.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 parameter
        E - the type parameter
        Parameters:
        collection - the collection
        invalidElement - 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 parameter
        TValue - the type parameter
        Parameters:
        map - the map
        invalidValue - 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 parameter
        TValue - 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 parameter
        TValue - 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 parameter
        TValue - 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 argument
        wrong - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 argument
        wrong - the that not
        errorMessage - 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 for
        filter - 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 for
        filter - 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 map
        TValue - the type of values in map
        Parameters:
        map - map in which we will look for
        filterValues - 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 map
        TValue - the type of values in map
        Parameters:
        map - map in which we will look for
        filterValues - 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 for
        filter - 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 map
        TValue - the type of values in map
        Parameters:
        map - Map in which we will look for
        filterValues - 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