try {
List<?> l = List.class.cast(obj);
// do extra validation:
for (Object o : l) {
if (!(o 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?
return (List<Double>)l;
} catch (ClassCastException e) {
// continue with others
}
if(obj instanceof String) {
String[] values = SPLIT.split((String) obj);
ArrayList<Double> doubleValue = new ArrayList<Double>(values.length);
for(String val : values) {
doubleValue.add(Double.parseDouble(val));
}
return doubleValue;
}
throw new WrongParameterValueException("Wrong parameter format! Parameter \"" + getName() + "\" requires a list of Double values!");
}