Skip to content

Commit

Permalink
Refactor MiddlewareRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldmensch committed Dec 10, 2024
1 parent 9271e3d commit dbe0cca
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,12 @@
public class MiddlewareRegistry {

private static final Logger log = LoggerFactory.getLogger(MiddlewareRegistry.class);
private final SortedMap<Priority, Set<Middleware>> middlewares;

/**
* Constructs a new MiddlewareRegistry.
*/
public MiddlewareRegistry() {
middlewares = new TreeMap<>();
middlewares.put(Priority.LOW, new HashSet<>());
middlewares.put(Priority.NORMAL, new HashSet<>());
middlewares.put(Priority.HIGH, new HashSet<>());
middlewares.put(Priority.PERMISSIONS, new HashSet<>());
register(Priority.PERMISSIONS, new PermissionsMiddleware());
register(Priority.NORMAL, new ConstraintMiddleware(), new CooldownMiddleware());
}
private final SortedMap<Priority, Set<Middleware>> middlewares = new TreeMap<>(Map.of(
Priority.LOW, new HashSet<>(),
Priority.NORMAL, new HashSet<>(Set.of(new ConstraintMiddleware(), new CooldownMiddleware())),
Priority.HIGH, new HashSet<>(),
Priority.PERMISSIONS, new HashSet<>(Set.of(new PermissionsMiddleware()))
));

/**
* Register {@link Middleware Middleware(s)} with the given {@link Priority}.
Expand Down

0 comments on commit dbe0cca

Please # to comment.