@Test void testMergeList() { List<KubernetesDeploymentTargetBuildItem> input = Arrays.asList( new KubernetesDeploymentTargetBuildItem("n1", "k1", 0, false), new KubernetesDeploymentTargetBuildItem("n2", "k2", 10, false), new KubernetesDeploymentTargetBuildItem("n1", "k1", -10, false), new KubernetesDeploymentTargetBuildItem("n3", "k3", Integer.MIN_VALUE, false), new KubernetesDeploymentTargetBuildItem("n4", "k4", Integer.MIN_VALUE, true), new KubernetesDeploymentTargetBuildItem("n2", "k2", -10, true), new KubernetesDeploymentTargetBuildItem("n4", "k4", Integer.MAX_VALUE, true), new KubernetesDeploymentTargetBuildItem("n1", "k1", 100, false)); List<KubernetesDeploymentTargetBuildItem> result = KubernetesDeploymentTargetBuildItem.mergeList(input); assertThat(result).containsOnly( new KubernetesDeploymentTargetBuildItem("n1", "k1", 100, false), new KubernetesDeploymentTargetBuildItem("n2", "k2", 10, true), new KubernetesDeploymentTargetBuildItem("n3", "k3", Integer.MIN_VALUE, false), new KubernetesDeploymentTargetBuildItem("n4", "k4", Integer.MAX_VALUE, true)); }
public static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input) { List<KubernetesDeploymentTargetBuildItem> result = new ArrayList<>(input.size()); Set<Map.Entry<String, String>> alreadyProcessedNameKindPairs = new HashSet<>(); for (KubernetesDeploymentTargetBuildItem candidate : input) { Map.Entry<String, String> nameToKindEntry = candidate.nameToKindEntry(); if (alreadyProcessedNameKindPairs.contains(nameToKindEntry)) { continue; } List<KubernetesDeploymentTargetBuildItem> nameAndKindMatchButNotEqual = input.stream() .filter(i -> i.nameAndKindMatchButNotEquals(candidate)).collect(Collectors.toList()); KubernetesDeploymentTargetBuildItem merged = candidate; for (KubernetesDeploymentTargetBuildItem toBeMerged : nameAndKindMatchButNotEqual) { merged = candidate.merge(toBeMerged); } result.add(merged); alreadyProcessedNameKindPairs.add(nameToKindEntry); } return result; }
KubernetesDeploymentTargetBuildItem extends MultiBuildItem implements Comparable<KubernetesDeploymentTargetBuildItem> { public static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input) { List<KubernetesDeploymentTargetBuildItem> result = new ArrayList<>(input.size()); Set<Map.Entry<String, String>> alreadyProcessedNameKindPairs = new HashSet<>(); for (KubernetesDeploymentTargetBuildItem candidate : input) { Map.Entry<String, String> nameToKindEntry = candidate.nameToKindEntry(); if (alreadyProcessedNameKindPairs.contains(nameToKindEntry)) { continue; } List<KubernetesDeploymentTargetBuildItem> nameAndKindMatchButNotEqual = input.stream() .filter(i -> i.nameAndKindMatchButNotEquals(candidate)).collect(Collectors.toList()); KubernetesDeploymentTargetBuildItem merged = candidate; for (KubernetesDeploymentTargetBuildItem toBeMerged : nameAndKindMatchButNotEqual) { merged = candidate.merge(toBeMerged); } result.add(merged); alreadyProcessedNameKindPairs.add(nameToKindEntry); } return result; } }
KubernetesDeploymentTargetBuildItem extends MultiBuildItem implements Comparable<KubernetesDeploymentTargetBuildItem> { public static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input) { List<KubernetesDeploymentTargetBuildItem> result = new ArrayList<>(input.size()); Set<Map.Entry<String, String>> alreadyProcessedNameKindPairs = new HashSet<>(); for (KubernetesDeploymentTargetBuildItem candidate : input) { Map.Entry<String, String> nameToKindEntry = candidate.nameToKindEntry(); if (alreadyProcessedNameKindPairs.contains(nameToKindEntry)) { continue; } List<KubernetesDeploymentTargetBuildItem> nameAndKindMatchButNotEqual = input.stream() .filter(i -> i.nameAndKindMatchButNotEquals(candidate)).collect(Collectors.toList()); KubernetesDeploymentTargetBuildItem merged = candidate; for (KubernetesDeploymentTargetBuildItem toBeMerged : nameAndKindMatchButNotEqual) { merged = candidate.merge(toBeMerged); } result.add(merged); alreadyProcessedNameKindPairs.add(nameToKindEntry); } return result; } KubernetesDeploymentTargetBuildItem(String name, String kind);  KubernetesDeploymentTargetBuildItem(String name, String kind, boolean enabled);  KubernetesDeploymentTargetBuildItem(String name, String kind, int priority, boolean enabled); }
KubernetesDeploymentTargetBuildItem extends MultiBuildItem implements Comparable<KubernetesDeploymentTargetBuildItem> { public static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input) { List<KubernetesDeploymentTargetBuildItem> result = new ArrayList<>(input.size()); Set<Map.Entry<String, String>> alreadyProcessedNameKindPairs = new HashSet<>(); for (KubernetesDeploymentTargetBuildItem candidate : input) { Map.Entry<String, String> nameToKindEntry = candidate.nameToKindEntry(); if (alreadyProcessedNameKindPairs.contains(nameToKindEntry)) { continue; } List<KubernetesDeploymentTargetBuildItem> nameAndKindMatchButNotEqual = input.stream() .filter(i -> i.nameAndKindMatchButNotEquals(candidate)).collect(Collectors.toList()); KubernetesDeploymentTargetBuildItem merged = candidate; for (KubernetesDeploymentTargetBuildItem toBeMerged : nameAndKindMatchButNotEqual) { merged = candidate.merge(toBeMerged); } result.add(merged); alreadyProcessedNameKindPairs.add(nameToKindEntry); } return result; } KubernetesDeploymentTargetBuildItem(String name, String kind);  KubernetesDeploymentTargetBuildItem(String name, String kind, boolean enabled);  KubernetesDeploymentTargetBuildItem(String name, String kind, int priority, boolean enabled); String getName(); String getKind(); int getPriority(); boolean isEnabled(); boolean nameAndKindMatch(KubernetesDeploymentTargetBuildItem other); boolean nameAndKindMatchButNotEquals(KubernetesDeploymentTargetBuildItem other); Map.Entry<String, String> nameToKindEntry(); @Override boolean equals(Object o); @Override int hashCode(); static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input); @Override int compareTo(KubernetesDeploymentTargetBuildItem o); }
KubernetesDeploymentTargetBuildItem extends MultiBuildItem implements Comparable<KubernetesDeploymentTargetBuildItem> { public static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input) { List<KubernetesDeploymentTargetBuildItem> result = new ArrayList<>(input.size()); Set<Map.Entry<String, String>> alreadyProcessedNameKindPairs = new HashSet<>(); for (KubernetesDeploymentTargetBuildItem candidate : input) { Map.Entry<String, String> nameToKindEntry = candidate.nameToKindEntry(); if (alreadyProcessedNameKindPairs.contains(nameToKindEntry)) { continue; } List<KubernetesDeploymentTargetBuildItem> nameAndKindMatchButNotEqual = input.stream() .filter(i -> i.nameAndKindMatchButNotEquals(candidate)).collect(Collectors.toList()); KubernetesDeploymentTargetBuildItem merged = candidate; for (KubernetesDeploymentTargetBuildItem toBeMerged : nameAndKindMatchButNotEqual) { merged = candidate.merge(toBeMerged); } result.add(merged); alreadyProcessedNameKindPairs.add(nameToKindEntry); } return result; } KubernetesDeploymentTargetBuildItem(String name, String kind);  KubernetesDeploymentTargetBuildItem(String name, String kind, boolean enabled);  KubernetesDeploymentTargetBuildItem(String name, String kind, int priority, boolean enabled); String getName(); String getKind(); int getPriority(); boolean isEnabled(); boolean nameAndKindMatch(KubernetesDeploymentTargetBuildItem other); boolean nameAndKindMatchButNotEquals(KubernetesDeploymentTargetBuildItem other); Map.Entry<String, String> nameToKindEntry(); @Override boolean equals(Object o); @Override int hashCode(); static List<KubernetesDeploymentTargetBuildItem> mergeList(List<KubernetesDeploymentTargetBuildItem> input); @Override int compareTo(KubernetesDeploymentTargetBuildItem o); static final int VANILLA_KUBERNETES_PRIORITY; static final int DEFAULT_PRIORITY; }