Skip to content

Commit

Permalink
Updates to instanceof with variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky8987 committed Jan 17, 2025
1 parent e78d617 commit 9716c1e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public FilteringWebHandler(List<GlobalFilter> globalFilters, boolean routeFilter
private static List<GatewayFilter> loadFilters(List<GlobalFilter> filters) {
return filters.stream().map(filter -> {
GatewayFilterAdapter gatewayFilter = new GatewayFilterAdapter(filter);
if (filter instanceof Ordered) {
int order = ((Ordered) filter).getOrder();
if (filter instanceof Ordered ordered) {
int order = ordered.getOrder();
return new OrderedGatewayFilter(gatewayFilter, order);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ List<GatewayFilter> loadGatewayFilters(String id, List<FilterDefinition> filterD

// some filters require routeId
// TODO: is there a better place to apply this?
if (configuration instanceof HasRouteId) {
HasRouteId hasRouteId = (HasRouteId) configuration;
if (configuration instanceof HasRouteId hasRouteId) {
hasRouteId.setRouteId(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public RouteRefreshListener(ApplicationEventPublisher publisher) {

@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
ContextRefreshedEvent refreshedEvent = (ContextRefreshedEvent) event;
if (event instanceof ContextRefreshedEvent refreshedEvent) {
boolean isManagementCtxt = WebServerApplicationContext
.hasServerNamespace(refreshedEvent.getApplicationContext(), "management");
boolean isLoadBalancerCtxt = refreshedEvent.getApplicationContext().getDisplayName() != null
Expand All @@ -58,13 +57,11 @@ public void onApplicationEvent(ApplicationEvent event) {
else if (event instanceof RefreshScopeRefreshedEvent || event instanceof InstanceRegisteredEvent) {
reset();
}
else if (event instanceof ParentHeartbeatEvent) {
ParentHeartbeatEvent e = (ParentHeartbeatEvent) event;
resetIfNeeded(e.getValue());
else if (event instanceof ParentHeartbeatEvent parentHeartbeatEvent) {
resetIfNeeded(parentHeartbeatEvent.getValue());
}
else if (event instanceof HeartbeatEvent) {
HeartbeatEvent e = (HeartbeatEvent) event;
resetIfNeeded(e.getValue());
else if (event instanceof HeartbeatEvent heartbeatEvent) {
resetIfNeeded(heartbeatEvent.getValue());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public boolean supportsParameter(MethodParameter parameter) {

private Type type(MethodParameter parameter) {
Type type = parameter.getGenericParameterType();
if (type instanceof ParameterizedType) {
ParameterizedType param = (ParameterizedType) type;
if (type instanceof ParameterizedType param) {
type = param.getActualTypeArguments()[0];
}
if (type instanceof TypeVariable || type instanceof WildcardType) {
Expand Down

0 comments on commit 9716c1e

Please sign in to comment.