Class PoolImplUtils


  • class PoolImplUtils
    extends Object
    Implementation specific utilities.
    Since:
    2.0
    • Constructor Detail

      • PoolImplUtils

        PoolImplUtils()
    • Method Detail

      • getFactoryType

        static Class<?> getFactoryType​(Class<? extends PooledObjectFactory> factoryClass)
        Identifies the concrete type of object that an object factory creates.
        Parameters:
        factoryClass - The factory to examine
        Returns:
        the type of object the factory creates
      • isPositive

        static boolean isPositive​(Duration delay)
      • max

        static Instant max​(Instant a,
                           Instant b)
        Returns the greater of two Instant values. That is, the result is the argument closer to the value of Instant.MAX. If the arguments have the same value, the result is that same value.
        Parameters:
        a - an argument.
        b - another argument.
        Returns:
        the larger of a and b.
      • min

        static Instant min​(Instant a,
                           Instant b)
        Returns the smaller of two Instant values. That is, the result is the argument closer to the value of Instant.MIN. If the arguments have the same value, the result is that same value.
        Parameters:
        a - an argument.
        b - another argument.
        Returns:
        the smaller of a and b.
      • toChronoUnit

        static ChronoUnit toChronoUnit​(TimeUnit timeUnit)
        Converts a TimeUnit to a ChronoUnit.
        Parameters:
        timeUnit - A TimeUnit.
        Returns:
        The corresponding ChronoUnit.
      • nonNull

        static Duration nonNull​(Duration value,
                                Duration defaultValue)
        Returns a non-null duration, value if non-null, otherwise defaultValue.
        Parameters:
        value - May be null.
        defaultValue - May not be null/
        Returns:
        value if non-null, otherwise defaultValue.
      • toDuration

        static Duration toDuration​(long amount,
                                   TimeUnit timeUnit)
        Converts am amount and TimeUnit into a Duration.
        Parameters:
        amount - the amount of the duration, measured in terms of the unit, positive or negative
        timeUnit - the unit that the duration is measured in, must have an exact duration, not null
        Returns:
        a Duration.