MCPcopy Create free account
hub / github.com/antlr/codebuff / wrap

Method wrap

output/java_guava/1.4.18/Primitives.java:121–128  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 3

wrapMethod · 0.95
castMethod · 0.95
castMethod · 0.95

Calls 2

getMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected