Package org.apache.commons.pool2.impl
Class PoolImplUtils
java.lang.Object
org.apache.commons.pool2.impl.PoolImplUtils
Implementation specific utilities.
- Since:
- 2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Class<?>getFactoryType(Class<? extends PooledObjectFactory> factoryClass) Identifies the concrete type of object that an object factory creates.private static <T> ObjectgetGenericType(Class<T> type, Class<? extends T> clazz) Gets the concrete type used by an implementation of an interface that uses a generic type.private static <T> ParameterizedTypegetParameterizedType(Class<T> type, Class<? extends T> clazz) Gets the matching parameterized type or null.private static ObjectgetTypeParameter(Class<?> clazz, 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 booleanisPositive(Duration delay) (package private) static InstantReturns the greater of twoInstantvalues.(package private) static InstantReturns the smaller of twoInstantvalues.(package private) static DurationReturns a non-null duration, value if non-null, otherwise defaultValue.(package private) static ChronoUnittoChronoUnit(TimeUnit timeUnit) Converts aTimeUnitto aChronoUnit.(package private) static DurationtoDuration(long amount, TimeUnit timeUnit) Converts am amount and TimeUnit into a Duration.
-
Constructor Details
-
PoolImplUtils
PoolImplUtils()
-
-
Method Details
-
getFactoryType
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
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 typeclazz- The class that implements the interface with a concrete type- Returns:
- concrete type used by the implementation
-
getParameterizedType
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
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 -
isPositive
-
max
Returns the greater of twoInstantvalues. That is, the result is the argument closer to the value ofInstant.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
aandb.
-
min
Returns the smaller of twoInstantvalues. That is, the result is the argument closer to the value ofInstant.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
aandb.
-
nonNull
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
Converts aTimeUnitto aChronoUnit.- Parameters:
timeUnit- A TimeUnit.- Returns:
- The corresponding ChronoUnit.
-
toDuration
Converts am amount and TimeUnit into a Duration.- Parameters:
amount- the amount of the duration, measured in terms of the unit, positive or negativetimeUnit- the unit that the duration is measured in, must have an exact duration, not null- Returns:
- a Duration.
-