Created
March 15, 2023 07:05
-
-
Save Hadevs/02c6ec31b0a9c44c95152c3c23a1353d 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>(); | |
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 (!commonColors.contains(color)) { | |
boolean isCommonInAllProviders = true; | |
for (String otherProvider : printProviders) { | |
if (!otherProvider.equals(printProvider)) { | |
VariantsResponse otherVariantsResponse = getVariants(blueprintId, otherProvider); | |
List<Variant> otherVariants = otherVariantsResponse.getVariants(); | |
boolean found = false; | |
for (Variant otherVariant : otherVariants) { | |
Options otherOptions = otherVariant.getOptions(); | |
if (otherOptions.getColor().equals(color)) { | |
found = true; | |
break; | |
} | |
} | |
if (!found) { | |
isCommonInAllProviders = false; | |
break; | |
} | |
} | |
} | |
if (isCommonInAllProviders) { | |
commonColors.add(color); | |
} | |
} | |
} | |
} | |
return commonColors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment