The following code works as expected:
private static void experiment() {
final UUID[] uuids = new UUID[]{null, UUID.randomUUID()};
final String[] names = new String[]{null, "", " ", "\t", "someName"};
final String[] descrs = new String[]{null, "", " ", "\t", "someDescr"};
final List<Arguments> allArguments = new ArrayList<>();
Arrays.stream(uuids)
.forEach(uuid -> Arrays.stream(names)
.forEach(name -> Arrays.stream(descrs)
.forEach(descr -> allArguments
.add(Arguments.of(uuid, name, descr)))));
}
allArguments
ends up with the following content (quasi-coded), consisting of 50 elements:
{
{null, null, null},
{null, null, ""},
...
{68dc3afc-a13e-405f-a761-12169e73ecf6, "someName", "someDescr"}
}
However, I would like two changes:
- I want
n
arrays of source values instead of the hardcoded three ones (uuids, names, descrs) - I want to solve the problem using streams in the following way:
final Collection<Arguments> allArguments =
<whatever>
<whatever>
...
.collect(<whatever>);
Could anybody come up with a suggestion to the problem?