Class PoolImplUtils


  • final class PoolImplUtils
    extends java.lang.Object
    Implementation specific utilities.
    Since:
    2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      PoolImplUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.lang.Class<?> getFactoryType​(java.lang.Class<? extends PooledObjectFactory> factoryClass)
      Identifies the concrete type of object that an object factory creates.
      private static <T> java.lang.Object getGenericType​(java.lang.Class<T> type, java.lang.Class<? extends T> clazz)
      Gets the concrete type used by an implementation of an interface that uses a generic type.
      private static <T> java.lang.reflect.ParameterizedType getParameterizedType​(java.lang.Class<T> type, java.lang.Class<? extends T> clazz)
      Gets the matching parameterized type or null.
      private static java.lang.Object getTypeParameter​(java.lang.Class<?> clazz, java.lang.reflect.Type argType)
      For a generic parameter, return either the Class used or if the type is unknown, the index for the type in definition of the class
      (package private) static boolean isPositive​(java.time.Duration delay)  
      (package private) static java.time.Instant max​(java.time.Instant a, java.time.Instant b)
      Returns the greater of two Instant values.
      (package private) static java.time.Instant min​(java.time.Instant a, java.time.Instant b)
      Returns the smaller of two Instant values.
      (package private) static java.time.Duration nonNull​(java.time.Duration value, java.time.Duration defaultValue)
      Returns a non-null duration, value if non-null, otherwise defaultValue.
      (package private) static java.time.temporal.ChronoUnit toChronoUnit​(java.util.concurrent.TimeUnit timeUnit)
      Converts a TimeUnit to a ChronoUnit.
      (package private) static java.time.Duration toDuration​(long amount, java.util.concurrent.TimeUnit timeUnit)
      Converts am amount and TimeUnit into a Duration.
      • Methods inherited from class java.lang.Object

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

      • PoolImplUtils

        PoolImplUtils()
    • Method Detail

      • getFactoryType

        static java.lang.Class<?> getFactoryType​(java.lang.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
      • getGenericType

        private static <T> java.lang.Object getGenericType​(java.lang.Class<T> type,
                                                           java.lang.Class<? extends T> clazz)
        Gets the concrete type used by an implementation of an interface that uses a generic type.
        Type Parameters:
        T - The interface type
        Parameters:
        type - The interface that defines a generic type
        clazz - The class that implements the interface with a concrete type
        Returns:
        concrete type used by the implementation
      • getParameterizedType

        private static <T> java.lang.reflect.ParameterizedType getParameterizedType​(java.lang.Class<T> type,
                                                                                    java.lang.Class<? extends T> clazz)
        Gets the matching parameterized type or null.
        Type Parameters:
        T - The interface type.
        Parameters:
        type - The interface that defines a generic type.
        clazz - The class that implements the interface with a concrete type.
        Returns:
        the matching parameterized type or null.
      • getTypeParameter

        private static java.lang.Object getTypeParameter​(java.lang.Class<?> clazz,
                                                         java.lang.reflect.Type argType)
        For a generic parameter, return either the Class used or if the type is unknown, the index for the type in definition of the class
        Parameters:
        clazz - defining class
        argType - the type argument of interest
        Returns:
        An instance of Class representing the type used by the type parameter or an instance of Integer representing the index for the type in the definition of the defining class
      • isPositive

        static boolean isPositive​(java.time.Duration delay)
      • max

        static java.time.Instant max​(java.time.Instant a,
                                     java.time.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 java.time.Instant min​(java.time.Instant a,
                                     java.time.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.
      • nonNull

        static java.time.Duration nonNull​(java.time.Duration value,
                                          java.time.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.
      • toChronoUnit

        static java.time.temporal.ChronoUnit toChronoUnit​(java.util.concurrent.TimeUnit timeUnit)
        Converts a TimeUnit to a ChronoUnit.
        Parameters:
        timeUnit - A TimeUnit.
        Returns:
        The corresponding ChronoUnit.
      • toDuration

        static java.time.Duration toDuration​(long amount,
                                             java.util.concurrent.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.