Created
March 15, 2023 09:22
-
-
Save Hadevs/355c6d70b0347a2c963a96b26bd2956f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<String> getCommonColors(String blueprintId, List<String> printProviders) throws IOException { | |
List<String> commonColors = new ArrayList<String>(); | |
Map<String, Boolean> colorsMap = new HashMap<>(); | |
for (String printProvider : printProviders) { | |
VariantsResponse variantsResponse = getVariants(blueprintId, printProvider); | |
List<Variant> variants = variantsResponse.getVariants(); | |
for (Variant variant : variants) { | |
Options options = variant.getOptions(); | |
String color = options.getColor(); | |
if(!colorsMap.containsKey(color)) { | |
colorsMap.put(color, true); | |
} else { | |
colorsMap.put(color, false); | |
} | |
} | |
} | |
for (Map.Entry<String, Boolean> entry : colorsMap.entrySet()) { | |
if (entry.getValue()) { | |
commonColors.add(entry.getKey()); | |
} | |
} | |
return commonColors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment