Returns the corresponding wrapper type of type if it is a primitive type; otherwise returns type itself. Idempotent. wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class
(Class<T> type)
| 119 | |
| 120 | |
| 121 | public static <T> Class<T> wrap(Class<T> type) { |
| 122 | checkNotNull(type); |
| 123 | |
| 124 | // cast is safe: long.class and Long.class are both of type Class<Long> |
| 125 | @SuppressWarnings("unchecked") |
| 126 | Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE.get(type); |
| 127 | return (wrapped == null) ? type : wrapped; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Returns the corresponding primitive type of {@code type} if it is a wrapper type; otherwise |
no test coverage detected