@Test public void createGroupListEmpty() throws Exception { assertEqualGroupList( ImmutableList.<ProductFlavorCombo>of(), ProductFlavorCombo.createCombinations( Collections.<String>emptyList(), Collections.<GroupableProductFlavorDsl>emptyList())); }
@NonNull public static List<ProductFlavorCombo> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<? extends GroupableProductFlavor> productFlavors) { List <ProductFlavorCombo> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (GroupableProductFlavor flavor : productFlavors) { result.add(new ProductFlavorCombo(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, GroupableProductFlavor> map = ArrayListMultimap.create(); for (GroupableProductFlavor flavor : productFlavors) { String flavorDimension = flavor.getFlavorDimension(); 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.getFlavorDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, new GroupableProductFlavor[flavorDimensions.size()], 0, flavorDimensions, map); } return result; }
ProductFlavorCombo { @NonNull public static List<ProductFlavorCombo> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<? extends GroupableProductFlavor> productFlavors) { List <ProductFlavorCombo> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (GroupableProductFlavor flavor : productFlavors) { result.add(new ProductFlavorCombo(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, GroupableProductFlavor> map = ArrayListMultimap.create(); for (GroupableProductFlavor flavor : productFlavors) { String flavorDimension = flavor.getFlavorDimension(); 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.getFlavorDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, new GroupableProductFlavor[flavorDimensions.size()], 0, flavorDimensions, map); } return result; } }
ProductFlavorCombo { @NonNull public static List<ProductFlavorCombo> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<? extends GroupableProductFlavor> productFlavors) { List <ProductFlavorCombo> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (GroupableProductFlavor flavor : productFlavors) { result.add(new ProductFlavorCombo(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, GroupableProductFlavor> map = ArrayListMultimap.create(); for (GroupableProductFlavor flavor : productFlavors) { String flavorDimension = flavor.getFlavorDimension(); 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.getFlavorDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, new GroupableProductFlavor[flavorDimensions.size()], 0, flavorDimensions, map); } return result; } ProductFlavorCombo(@NonNull GroupableProductFlavor... flavors);  ProductFlavorCombo(@NonNull Iterable<GroupableProductFlavor> flavors); }
ProductFlavorCombo { @NonNull public static List<ProductFlavorCombo> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<? extends GroupableProductFlavor> productFlavors) { List <ProductFlavorCombo> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (GroupableProductFlavor flavor : productFlavors) { result.add(new ProductFlavorCombo(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, GroupableProductFlavor> map = ArrayListMultimap.create(); for (GroupableProductFlavor flavor : productFlavors) { String flavorDimension = flavor.getFlavorDimension(); 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.getFlavorDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, new GroupableProductFlavor[flavorDimensions.size()], 0, flavorDimensions, map); } return result; } ProductFlavorCombo(@NonNull GroupableProductFlavor... flavors);  ProductFlavorCombo(@NonNull Iterable<GroupableProductFlavor> flavors); @NonNull String getName(); @NonNull List<GroupableProductFlavor> getFlavorList(); @NonNull static List<ProductFlavorCombo> createCombinations(
            @Nullable List<String> flavorDimensions,
            @NonNull Iterable<? extends GroupableProductFlavor> productFlavors); }
ProductFlavorCombo { @NonNull public static List<ProductFlavorCombo> createCombinations( @Nullable List<String> flavorDimensions, @NonNull Iterable<? extends GroupableProductFlavor> productFlavors) { List <ProductFlavorCombo> result = Lists.newArrayList(); if (flavorDimensions == null || flavorDimensions.isEmpty()) { for (GroupableProductFlavor flavor : productFlavors) { result.add(new ProductFlavorCombo(ImmutableList.of(flavor))); } } else { ArrayListMultimap<String, GroupableProductFlavor> map = ArrayListMultimap.create(); for (GroupableProductFlavor flavor : productFlavors) { String flavorDimension = flavor.getFlavorDimension(); 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.getFlavorDimension())); } map.put(flavorDimension, flavor); } createProductFlavorCombinations(result, new GroupableProductFlavor[flavorDimensions.size()], 0, flavorDimensions, map); } return result; } ProductFlavorCombo(@NonNull GroupableProductFlavor... flavors);  ProductFlavorCombo(@NonNull Iterable<GroupableProductFlavor> flavors); @NonNull String getName(); @NonNull List<GroupableProductFlavor> getFlavorList(); @NonNull static List<ProductFlavorCombo> createCombinations(
            @Nullable List<String> flavorDimensions,
            @NonNull Iterable<? extends GroupableProductFlavor> productFlavors);  }