Skip to content

Commit

Permalink
feat: add RestInterceptorRegistration for RestInterceptor configurati…
Browse files Browse the repository at this point in the history
…on - #1

- RestInterceptorRegistration manages RestInterceptor configuration.
- Allows adding multiple RestfulPattern objects to the interceptor.
- Provides method to set the order of execution.
- Supports flexible configuration of interceptors by modifying patterns and order.
- Helper methods include `addRestfulPatterns` and `order` for customization.
  • Loading branch information
Dh3356 committed Nov 27, 2024
1 parent fcd2e11 commit 5ad9b4e
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.restful_spring.rest_interceptor;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class RestInterceptorRegistration {

private final RestInterceptor restInterceptor;
private int order = 0;

public RestInterceptorRegistration(RestInterceptor restInterceptor) {
this.restInterceptor = restInterceptor;
}

public RestInterceptorRegistration addRestfulPatterns(RestfulPattern... restfulPatterns) {
return addRestfulPatterns(List.of(restfulPatterns));
}

public RestInterceptorRegistration addRestfulPatterns(Collection<RestfulPattern> restfulPatterns) {
restInterceptor.restfulPatterns = new ArrayList<>(restfulPatterns);
return this;
}

public RestInterceptorRegistration order(int order) {
this.order = order;
return this;
}

protected RestInterceptor getRestInterceptor() {
return restInterceptor;
}

protected int getOrder() {
return order;
}
}

0 comments on commit 5ad9b4e

Please sign in to comment.