javax.enterprise.inject.spi.Prioritized Java Examples

The following examples show how to use javax.enterprise.inject.spi.Prioritized. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Channels.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static List<ClientInterceptor> getSortedInterceptors(Instance<ClientInterceptor> interceptors) {
    if (interceptors.isUnsatisfied()) {
        return Collections.emptyList();
    }

    return interceptors.stream().sorted(new Comparator<ClientInterceptor>() { // NOSONAR
        @Override
        public int compare(ClientInterceptor si1, ClientInterceptor si2) {
            int p1 = 0;
            int p2 = 0;
            if (si1 instanceof Prioritized) {
                p1 = ((Prioritized) si1).getPriority();
            }
            if (si2 instanceof Prioritized) {
                p2 = ((Prioritized) si2).getPriority();
            }
            if (si1.equals(si2)) {
                return 0;
            }
            return Integer.compare(p1, p2);
        }
    }).collect(Collectors.toList());
}
 
Example #2
Source File: GrpcContainer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
List<ServerInterceptor> getSortedInterceptors() {
    if (interceptors.isUnsatisfied()) {
        return Collections.emptyList();
    }

    return interceptors.stream().sorted(new Comparator<ServerInterceptor>() { // NOSONAR
        @Override
        public int compare(ServerInterceptor si1, ServerInterceptor si2) {
            int p1 = 0;
            int p2 = 0;
            if (si1 instanceof Prioritized) {
                p1 = ((Prioritized) si1).getPriority();
            }
            if (si2 instanceof Prioritized) {
                p2 = ((Prioritized) si2).getPriority();
            }
            if (si1.equals(si2)) {
                return 0;
            }
            return Integer.compare(p1, p2);
        }
    }).collect(Collectors.toList());
}