Class CRetry


  • public class CRetry
    extends java.lang.Object
    It happens that we need to retry an action many times depend on some criteria. To have the retry logic concentrated and avoid potential dead loop or make the code noisy we move the logic here.
    • Constructor Summary

      Constructors 
      Constructor Description
      CRetry()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if any exception throws by result of the function get.
      static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if any exception throws by result of the function get.
      static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if any exception throws by result of the function get.
      static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIf, int retryCount, int interval)
      Retry the function get if the predicate retryIf returns true.
      static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIf, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the predicate retryIf returns true.
      static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIf, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the predicate retryIf returns true.
      static <R extends java.util.Collection>
      R
      retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is an empty collection.
      static <R extends java.util.Collection>
      R
      retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is an empty collection.
      static <R extends java.util.Collection>
      R
      retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is an empty collection.
      static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is Boolean.false or null.
      static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is Boolean.false or null.
      static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is Boolean.false or null.
      static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIfNot, int retryCount, int interval)
      Retry the function if the predicate retryIfNot returns false.
      static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIfNot, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function if the predicate retryIfNot returns false.
      static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m, java.util.function.Predicate<R> retryIfNot, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function if the predicate retryIfNot returns false.
      static <R extends java.util.Collection>
      R
      retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is not an empty collection.
      static <R extends java.util.Collection>
      R
      retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is not an empty collection.
      static <R extends java.util.Collection>
      R
      retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is not an empty collection.
      static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is not an null collection.
      static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is not an null collection.
      static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is not an null collection.
      static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is null.
      static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is null.
      static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is null.
      static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval)
      Retry the function get if the result of get is Boolean.true.
      static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse)
      Retry the function get if the result of get is Boolean.true.
      static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m, int retryCount, int interval, java.util.function.Supplier<R> orElse, boolean throwLastException)
      Retry the function get if the result of get is Boolean.true.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CRetry

        public CRetry()
    • Method Detail

      • retryIf

        public static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m,
                                    java.util.function.Predicate<R> retryIf,
                                    int retryCount,
                                    int interval)
        Retry the function get if the predicate retryIf returns true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIf - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIf

        public static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m,
                                    java.util.function.Predicate<R> retryIf,
                                    int retryCount,
                                    int interval,
                                    java.util.function.Supplier<R> orElse)
        Retry the function get if the predicate retryIf returns true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIf - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIf

        public static <R> R retryIf​(java.util.function.Function<java.lang.Integer,​R> m,
                                    java.util.function.Predicate<R> retryIf,
                                    int retryCount,
                                    int interval,
                                    @Nullable
                                    java.util.function.Supplier<R> orElse,
                                    boolean throwLastException)
        Retry the function get if the predicate retryIf returns true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIf - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during invocation at the end or not
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNot

        public static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m,
                                       java.util.function.Predicate<R> retryIfNot,
                                       int retryCount,
                                       int interval)
        Retry the function if the predicate retryIfNot returns false. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIfNot - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfNot

        public static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m,
                                       java.util.function.Predicate<R> retryIfNot,
                                       int retryCount,
                                       int interval,
                                       java.util.function.Supplier<R> orElse)
        Retry the function if the predicate retryIfNot returns false. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIfNot - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNot

        public static <R> R retryIfNot​(java.util.function.Function<java.lang.Integer,​R> m,
                                       java.util.function.Predicate<R> retryIfNot,
                                       int retryCount,
                                       int interval,
                                       @Nullable
                                       java.util.function.Supplier<R> orElse,
                                       boolean throwLastException)
        Retry the function if the predicate retryIfNot returns false. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryIfNot - predicate to be test
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during invocation at the end or not
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfFalse

        public static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m,
                                         int retryCount,
                                         int interval)
        Retry the function get if the result of get is Boolean.false or null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfFalse

        public static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m,
                                         int retryCount,
                                         int interval,
                                         java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is Boolean.false or null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfFalse

        public static <R> R retryIfFalse​(java.util.function.Function<java.lang.Integer,​R> m,
                                         int retryCount,
                                         int interval,
                                         java.util.function.Supplier<R> orElse,
                                         boolean throwLastException)
        Retry the function get if the result of get is Boolean.false or null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfTrue

        public static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval)
        Retry the function get if the result of get is Boolean.true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfTrue

        public static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval,
                                        java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is Boolean.true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfTrue

        public static <R> R retryIfTrue​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval,
                                        java.util.function.Supplier<R> orElse,
                                        boolean throwLastException)
        Retry the function get if the result of get is Boolean.true. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfEmpty

        public static <R extends java.util.Collection> R retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                      int retryCount,
                                                                      int interval)
        Retry the function get if the result of get is an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfEmpty

        public static <R extends java.util.Collection> R retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                      int retryCount,
                                                                      int interval,
                                                                      java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfEmpty

        public static <R extends java.util.Collection> R retryIfEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                      int retryCount,
                                                                      int interval,
                                                                      java.util.function.Supplier<R> orElse,
                                                                      boolean throwLastException)
        Retry the function get if the result of get is an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNotEmpty

        public static <R extends java.util.Collection> R retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                         int retryCount,
                                                                         int interval)
        Retry the function get if the result of get is not an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfNotEmpty

        public static <R extends java.util.Collection> R retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                         int retryCount,
                                                                         int interval,
                                                                         java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is not an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNotEmpty

        public static <R extends java.util.Collection> R retryIfNotEmpty​(java.util.function.Function<java.lang.Integer,​R> m,
                                                                         int retryCount,
                                                                         int interval,
                                                                         java.util.function.Supplier<R> orElse,
                                                                         boolean throwLastException)
        Retry the function get if the result of get is not an empty collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNull

        public static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval)
        Retry the function get if the result of get is null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfNull

        public static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval,
                                        java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNull

        public static <R> R retryIfNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                        int retryCount,
                                        int interval,
                                        java.util.function.Supplier<R> orElse,
                                        boolean throwLastException)
        Retry the function get if the result of get is null. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNotNull

        public static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                           int retryCount,
                                           int interval)
        Retry the function get if the result of get is not an null collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retryIfNotNull

        public static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                           int retryCount,
                                           int interval,
                                           java.util.function.Supplier<R> orElse)
        Retry the function get if the result of get is not an null collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retryIfNotNull

        public static <R> R retryIfNotNull​(java.util.function.Function<java.lang.Integer,​R> m,
                                           int retryCount,
                                           int interval,
                                           java.util.function.Supplier<R> orElse,
                                           boolean throwLastException)
        Retry the function get if the result of get is not an null collection. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retry

        public static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m,
                                  int retryCount,
                                  int interval)
        Retry the function get if any exception throws by result of the function get. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        Returns:
        result of m method get or null if all retry failed
      • retry

        public static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m,
                                  int retryCount,
                                  int interval,
                                  java.util.function.Supplier<R> orElse)
        Retry the function get if any exception throws by result of the function get. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.
      • retry

        public static <R> R retry​(java.util.function.Function<java.lang.Integer,​R> m,
                                  int retryCount,
                                  int interval,
                                  java.util.function.Supplier<R> orElse,
                                  boolean throwLastException)
        Retry the function get if any exception throws by result of the function get. Please note that we throw runtime exception which wrap the original exception so we do not have to add throwable to all method deceleration.
        Type Parameters:
        R - type of returned object
        Parameters:
        m - function to be called
        retryCount - maximum number of retry
        interval - interval between retries in milliseconds
        orElse - supplier to generate alternative result if retryIf result was always true, returns null if the supplier is null
        throwLastException - whether we should throw exception which has been throws during get at the end
        Returns:
        result of m method get. if all retry failed then return orElse invocation result or null if orElse is null.