Returns the corresponding wrapper type of {@code type} if it is a primitive type; otherwise returns {@code type} itself. Idempotent. <pre> wrap(int.class) == Integer.class wrap(Integer.class) == Integer.class wrap(String.class) == String.class </pre>
(Class<T> type)
| 61 | * </pre> |
| 62 | */ |
| 63 | @SuppressWarnings({class="st">"unchecked", class="st">"MissingBraces"}) |
| 64 | public static <T> Class<T> wrap(Class<T> type) { |
| 65 | if (type == int.class) return (Class<T>) Integer.class; |
| 66 | if (type == float.class) return (Class<T>) Float.class; |
| 67 | if (type == byte.class) return (Class<T>) Byte.class; |
| 68 | if (type == double.class) return (Class<T>) Double.class; |
| 69 | if (type == long.class) return (Class<T>) Long.class; |
| 70 | if (type == char.class) return (Class<T>) Character.class; |
| 71 | if (type == boolean.class) return (Class<T>) Boolean.class; |
| 72 | if (type == short.class) return (Class<T>) Short.class; |
| 73 | if (type == void.class) return (Class<T>) Void.class; |
| 74 | return type; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Returns the corresponding primitive type of {@code type} if it is a wrapper type; otherwise |
no outgoing calls