if (currentTypeIndex == options.size()) {
result.add(currentPermutation);
return result;
}
ProductOption currentOption = options.get(currentTypeIndex);
if (!currentOption.getUseInSkuGeneration()) {
//This flag means do not generate skus and so do not create permutations for this productoption,
//end it here and return the current list of permutations.
result.addAll(generatePermutations(currentTypeIndex + 1, currentPermutation, options));
return result;
}
for (ProductOptionValue option : currentOption.getAllowedValues()) {
List<ProductOptionValue> permutation = new ArrayList<ProductOptionValue>();
permutation.addAll(currentPermutation);
permutation.add(option);
result.addAll(generatePermutations(currentTypeIndex + 1, permutation, options));
}
if (currentOption.getAllowedValues().size() == 0) {
//There are still product options left in our array to compute permutations, even though this productOption does not have any values associated.
result.addAll(generatePermutations(currentTypeIndex + 1, currentPermutation, options));
}
return result;