I have the following method in Java 8 and I'm working in project using java 7:
public <T> List<T> getValues(CommandLineItem commandLineItemMod, Class<T> targetClass) {
Object value = values.get(commandLineItemMod);
ArrayList<T> result = new ArrayList<>();
if (value instanceof Collection) {
Collection<?> sourceCollection = (Collection<?>) value;
result.ensureCapacity(sourceCollection.size());
sourceCollection.stream().map(o -> convertValue(o, targetClass)).forEach(result::add);
} else if (value != null) {
result.add(convertValue(value, targetClass));
}
return result;
}
my question is how I can transfer the following line from java 8 to java 7 :
sourceCollection.stream().map(o -> convertValue(o, targetClass)).forEach(result::add);
thank you for your help