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)
| 93 | * </pre> |
| 94 | */ |
| 95 | public static <T> Class<T> wrap(Class<T> type) { |
| 96 | // cast is safe: long.class and Long.class are both of type Class<Long> |
| 97 | @SuppressWarnings("unchecked") |
| 98 | Class<T> wrapped = (Class<T>) PRIMITIVE_TO_WRAPPER_TYPE.get( |
| 99 | $Gson$Preconditions.checkNotNull(type)); |
| 100 | return (wrapped == null) ? type : wrapped; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Returns the corresponding primitive type of {@code type} if it is a |