class ProductFlavorCombo {

    @NonNull
    public static <S extends DimensionAware & Named> List<ProductFlavorCombo<S>> createCombinations(
            @Nullable List<String> flavorDimensions,
            @NonNull Iterable<S> productFlavors) {

        List <ProductFlavorCombo<S>> result = Lists.newArrayList();
        if (flavorDimensions == null || flavorDimensions.isEmpty()) {
            for (S flavor : productFlavors) {
                result.add(new ProductFlavorCombo<>(ImmutableList.of(flavor)));
            }
        } else {
            // need to group the flavor per dimension.
            // First a map of dimension -> list(ProductFlavor)
            ArrayListMultimap<String, S> map = ArrayListMultimap.create();
            for (S flavor : productFlavors) {
                String flavorDimension = flavor.getDimension();

                if (flavorDimension == null) {
                    throw new RuntimeException(String.format(
                            "Flavor '%1$s' has no flavor dimension.", flavor.getName()));
                }
                if (!flavorDimensions.contains(flavorDimension)) {
                    throw new RuntimeException(String.format(
                            "Flavor '%1$s' has unknown dimension '%2$s'.",
                            flavor.getName(), flavor.getDimension()));
                }

                map.put(flavorDimension, flavor);
            }

            createProductFlavorCombinations(result,
                    Lists.<S>newArrayListWithCapacity(flavorDimensions.size()),
                    0, flavorDimensions, map);
        }
        return result;
    }

    public  ProductFlavorCombo(@NonNull T... flavors);
    public  ProductFlavorCombo(@NonNull Iterable<T> flavors);

}