Skip to content
Open
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 @@ -69,9 +69,14 @@ static Class<?> getRawType(Type type) {
}

static Class<?> getArrayClass(Class<?> componentType) {
// TODO(user): This is not the most efficient way to handle generic
// arrays, but is there another way to extract the array class in a
// non-hacky way (i.e. using String value class names- "[L...")?
return Array.newInstance(componentType, 0).getClass();
try {
return Class.forName("[L" + componentType.getName() + ";");
} catch (ClassNotFoundException e) {
try {
return Array.newInstance(componentType, 0).getClass();
} catch (Exception ex) {
throw new IllegalArgumentException("Error getting array type. ", e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.squirrelframework.foundation.util;

import com.google.common.reflect.TypeToken;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;

public class TypeReferenceTest {

@Test
public void testArrayTypeDiscovery() {
TypeReference<List<String>> typeReference = new TypeReference<List<String>>() {};

assertEquals(typeReference.getType(), new TypeToken<List<String>>() {}.getType());
}
}