Question
Use collect to return List<particular type> instead of List<Object>
I want to collect List<TestClone>
, but looks like .collect()
returns only List<Object>
. Is there a way I can get List<TestClone>
?
I know .toArray()
is there, but want an ArrayList
.
public static List<TestClone> getTypes(List<TestClone> args)
{
return args.stream().map(e -> {
if (e.schema == null)
{
return getAllExportArgs(e);
}
else
{
return e;
}
}).collect(Collectors.toCollection(ArrayList<TestClone>::new)); //TODO: ?
}
public static List<TestClone> getAllExportArgs(TestClone args)
{
//returns List<TestClone>
}
4 90
4