MCPcopy
hub / github.com/google/gson / wrap

Method wrap

gson/src/main/java/com/google/gson/internal/Primitives.java:63–75  ·  gson/src/main/java/com/google/gson/internal/Primitives.java::Primitives.wrap

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)

Source from the content-addressed store, hash-verified

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

Callers 3

adaptTypeMethod · 0.95
getExpectedJsonMethod · 0.95
fromJsonMethod · 0.95

Calls

no outgoing calls

Tested by 2

adaptTypeMethod · 0.76
getExpectedJsonMethod · 0.76