Skip to content

Commit

Permalink
Merge pull request #25555 from geoand/arc-runtime-lambda
Browse files Browse the repository at this point in the history
Get rid of a lambda in Arc runtime code
  • Loading branch information
geoand authored May 13, 2022
2 parents 65175c1 + 5abb012 commit bd3b19f
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.InjectionPoint;

public final class Instances {

static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[] {};

static final Comparator<InjectableBean<?>> PRIORITY_COMPARATOR = Collections
.reverseOrder(Comparator.comparingInt(InjectableBean::getPriority));
static final Comparator<InjectableBean<?>> PRIORITY_COMPARATOR = new Comparator<>() {
@Override
public int compare(InjectableBean<?> ib1, InjectableBean<?> ib2) {
return Integer.compare(ib2.getPriority(), ib1.getPriority());
}
};

private Instances() {
}
Expand All @@ -32,12 +34,16 @@ public static List<InjectableBean<?>> resolveBeans(Type requiredType, Set<Annota
}

public static List<InjectableBean<?>> resolveBeans(Type requiredType, Annotation... requiredQualifiers) {
return ArcContainerImpl.instance()
.getResolvedBeans(requiredType, requiredQualifiers)
.stream()
.filter(Predicate.not(InjectableBean::isSuppressed))
.sorted(PRIORITY_COMPARATOR)
.collect(Collectors.toUnmodifiableList());
Set<InjectableBean<?>> resolvedBeans = ArcContainerImpl.instance()
.getResolvedBeans(requiredType, requiredQualifiers);
List<InjectableBean<?>> nonSuppressed = new ArrayList<>(resolvedBeans.size());
for (InjectableBean<?> injectableBean : resolvedBeans) {
if (!injectableBean.isSuppressed()) {
nonSuppressed.add(injectableBean);
}
}
nonSuppressed.sort(PRIORITY_COMPARATOR);
return List.copyOf(nonSuppressed);
}

@SuppressWarnings("unchecked")
Expand Down

0 comments on commit bd3b19f

Please sign in to comment.