// do extra validation:
for(Object o : l) {
List<?> v = List.class.cast(o);
for(Object c : v) {
if(!(c instanceof Double)) {
throw new WrongParameterValueException("Wrong parameter format for parameter \"" + getName() + "\". Given list contains objects of different type!");
}
}
}
// TODO: can we use reflection to get extra checks?
// TODO: Should we copy the list and vectors?
return (List<List<Double>>) l;
}
catch(ClassCastException e) {
// continue with other attempts.
}
if(obj instanceof String) {
String[] vectors = VECTOR_SPLIT.split((String) obj);
if(vectors.length == 0) {
throw new UnspecifiedParameterException("Wrong parameter format! Given list of vectors for parameter \"" + getName() + "\" is empty!");
}
ArrayList<List<Double>> vecs = new ArrayList<List<Double>>();
for(String vector : vectors) {
String[] coordinates = SPLIT.split(vector);
ArrayList<Double> vectorCoord = new ArrayList<Double>();
for(String coordinate : coordinates) {
try {
Double.parseDouble(coordinate);
vectorCoord.add(Double.parseDouble(coordinate));
}
catch(NumberFormatException e) {
throw new WrongParameterValueException("Wrong parameter format! Coordinates of vector \"" + vector + "\" are not valid!");
}
}
vecs.add(vectorCoord);
}
return vecs;
}
throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a list of Double values!");
}