Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public enum HierarchyTraversalMode {

classNameToTypeMap = Collections.unmodifiableMap(classNamesToTypes);

Map<Class<?>, Class<?>> primitivesToWrappers = new IdentityHashMap<>(9);
Map<Class<?>, Class<?>> primitivesToWrappers = new IdentityHashMap<>(8);

primitivesToWrappers.put(boolean.class, Boolean.class);
primitivesToWrappers.put(byte.class, Byte.class);
Expand Down Expand Up @@ -564,7 +564,7 @@ static boolean isWideningConversion(Class<?> sourceType, Class<?> targetType) {
*
* @param type the primitive type for which to retrieve the wrapper type
* @return the corresponding wrapper type or {@code null} if the
* supplied type is {@code null} or not a primitive type
* supplied type is not a primitive type
*/
public static @Nullable Class<?> getWrapperType(Class<?> type) {
return primitiveToWrapperMap.get(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -213,6 +214,19 @@ void wideningConversion() {
assertFalse(isWideningConversion(String.class, int.class)); // neither a primitive nor a wrapper
}

@Test
void getWrapperType() {
assertEquals(Boolean.class, ReflectionUtils.getWrapperType(boolean.class));
assertEquals(Byte.class, ReflectionUtils.getWrapperType(byte.class));
assertEquals(Character.class, ReflectionUtils.getWrapperType(char.class));
assertEquals(Short.class, ReflectionUtils.getWrapperType(short.class));
assertEquals(Integer.class, ReflectionUtils.getWrapperType(int.class));
assertEquals(Long.class, ReflectionUtils.getWrapperType(long.class));
assertEquals(Float.class, ReflectionUtils.getWrapperType(float.class));
assertEquals(Double.class, ReflectionUtils.getWrapperType(double.class));
assertNull(ReflectionUtils.getWrapperType(Object.class));
}

@Test
void getAllClasspathRootDirectories(@TempDir Path tempDirectory) throws Exception {
var root1 = tempDirectory.resolve("root1").toAbsolutePath();
Expand Down