public static <T> T primitiveArrayValue(Instance obj) {
if (obj == null) {
return null;
}
if (obj instanceof PrimitiveArrayInstance) {
PrimitiveArrayInstance pa = (PrimitiveArrayInstance) obj;
String type = pa.getJavaClass().getName();
Object array;
int len = pa.getLength();
if ("boolean[]".equals(type)) {
array = new boolean[len];
}
else if ("byte[]".equals(type)) {
array = new byte[len];
}
else if ("char[]".equals(type)) {
array = new char[len];
}
else if ("short[]".equals(type)) {
array = new short[len];
}
else if ("int[]".equals(type)) {
array = new int[len];
}
else if ("long[]".equals(type)) {
array = new long[len];
}
else if ("float[]".equals(type)) {
array = new float[len];
}
else if ("double[]".equals(type)) {
array = new double[len];
}
else {
throw new IllegalArgumentException("Is not a primitive array: " + obj.getInstanceId() + " (" + obj.getJavaClass().getName() + ")");
}
List<Object> values = pa.getValues();
for(int i = 0; i != values.size(); ++i) {
Object val = values.get(i);
if (val instanceof String) {
val = Character.valueOf(((String)val).charAt(0));
}