|
34 | 34 | public interface PooledObject<T> extends Comparable<PooledObject<T>> { |
35 | 35 |
|
36 | 36 | /** |
37 | | - * Tests whether the given PooledObject is null <em>or</em> contains a null. |
| 37 | + * Gets the wrapped object or null. |
38 | 38 | * |
39 | | - * @param pooledObject the PooledObject to test. |
40 | | - * @return whether the given PooledObject is null <em>or</em> contains a null. |
| 39 | + * @param <T> the type of object in the pool. |
| 40 | + * @param pooledObject the PooledObject to unwrap, may be null. |
| 41 | + * @return the wrapped object or null. |
| 42 | + * @since 2.13.0 |
| 43 | + */ |
| 44 | + static <T> T getObject(final PooledObject<T> pooledObject) { |
| 45 | + return pooledObject != null ? pooledObject.getObject() : null; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Tests whether the given PooledObject is null <em>or</em> wraps a null. |
| 50 | + * |
| 51 | + * @param pooledObject the PooledObject to test, may be null. |
| 52 | + * @return whether the given PooledObject is null <em>or</em> wraps a null. |
41 | 53 | * @since 2.12.0 |
42 | 54 | */ |
43 | 55 | static boolean isNull(final PooledObject<?> pooledObject) { |
44 | | - return pooledObject == null || pooledObject.getObject() == null; |
| 56 | + return getObject(pooledObject) == null; |
45 | 57 | } |
46 | 58 |
|
47 | 59 | /** |
48 | 60 | * Tests whether the given PooledObject isn't null <em>and</em> doesn't wraps a null. |
49 | 61 | * |
50 | | - * @param pooledObject the PooledObject to test. |
| 62 | + * @param pooledObject the PooledObject to test, may be null. |
51 | 63 | * @return whether the given PooledObject isn't null <em>and</em> doesn't wraps a null. |
52 | 64 | * @since 2.13.0 |
53 | 65 | */ |
54 | 66 | static boolean nonNull(final PooledObject<?> pooledObject) { |
55 | | - return pooledObject != null && pooledObject.getObject() != null; |
| 67 | + return getObject(pooledObject) != null; |
56 | 68 | } |
57 | 69 |
|
58 | 70 | /** |
|
0 commit comments