jeudi 20 juillet 2017

Check if object is a Matrix

I need to test if an Object is a Matrix or Array.

For example I've got:

String[] array;
String[][] matrix;

I'm using:

private boolean isVector(Class<?> clazz) {
    return clazz.isArray();
}
private boolean isMatrix(Class<?> clazz) {
    return clazz.getSimpleName().endsWith("[][]");
}

But I don't want to use clazz.getSimpleName() because is very slow (almost 10% of my execution time according to JProfiler), is there another way to test if an Object is a matrix?

I can't use instanceof because it can be a matrix of any object.





Aucun commentaire:

Enregistrer un commentaire