Files
2026-11-21 17:07:18 -05:00

81 lines
2.3 KiB
Java

/* */ package kong.unirest.cosmetics;
/* */
/* */ import java.util.ArrayList;
/* */ import java.util.Collections;
/* */ import java.util.List;
/* */ import java.util.Optional;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ class CompoundInterceptor
/* */ implements Interceptor
/* */ {
/* */ private List<Interceptor> interceptors;
/* */
/* */ CompoundInterceptor() {
/* 34 */ this(Collections.singletonList(new DefaultInterceptor()));
/* */ }
/* */
/* */ CompoundInterceptor(List<Interceptor> interceptors) {
/* 38 */ this.interceptors = interceptors;
/* */ }
/* */
/* */
/* */ public void onRequest(HttpRequest<?> request, Config config) {
/* 43 */ this.interceptors.forEach(i -> i.onRequest(request, config));
/* */ }
/* */
/* */
/* */ public void onResponse(HttpResponse<?> response, HttpRequestSummary request, Config config) {
/* 48 */ this.interceptors.forEach(i -> i.onResponse(response, request, config));
/* */ }
/* */
/* */
/* */ public HttpResponse<?> onFail(Exception e, HttpRequestSummary request, Config config) throws UnirestException {
/* 53 */ return (HttpResponse)this.interceptors.stream()
/* 54 */ .map(i -> Optional.ofNullable(i.onFail(e, request, config)))
/* 55 */ .flatMap(Util::stream)
/* 56 */ .findFirst()
/* 57 */ .orElseThrow(() -> new UnirestException(e));
/* */ }
/* */
/* */ int size() {
/* 61 */ return this.interceptors.size();
/* */ }
/* */
/* */ List<Interceptor> getInterceptors() {
/* 65 */ return new ArrayList<>(this.interceptors);
/* */ }
/* */
/* */ void register(Interceptor t1) {
/* 69 */ if (this.interceptors.stream().anyMatch(i -> i instanceof DefaultInterceptor)) {
/* 70 */ this.interceptors = new ArrayList<>();
/* */ }
/* 72 */ if (!this.interceptors.contains(t1))
/* 73 */ this.interceptors.add(t1);
/* */ }
/* */ }
/* Location: C:\Users\Xiao\Downloads\MinehutCosmetics.jar!\kon\\unirest\cosmetics\CompoundInterceptor.class
* Java compiler version: 11 (55.0)
* JD-Core Version: 1.1.3
*/