} else if (baseClass == float.class) {
return FloatArrayTemplate.getInstance();
} else if (baseClass == double.class) {
return DoubleArrayTemplate.getInstance();
} else {
Template baseTemplate = registry.lookup(genericBaseType);
return new ObjectArrayTemplate(baseClass, baseTemplate);
}
} else if (dim == 2) {
Class componentClass = Array.newInstance(baseClass, 0).getClass();
Template componentTemplate = toTemplate(arrayType, genericBaseType, baseClass, dim - 1);
return new ReflectionMultidimentionalArrayTemplate(componentClass, componentTemplate);
} else {
ReflectionMultidimentionalArrayTemplate componentTemplate =
(ReflectionMultidimentionalArrayTemplate) toTemplate(arrayType, genericBaseType, baseClass, dim - 1);
Class componentClass = Array.newInstance(componentTemplate.getComponentClass(), 0).getClass();
return new ReflectionMultidimentionalArrayTemplate(componentClass, componentTemplate);
}
}