Updates to instanceof with variable

Signed-off-by: lucky8987 <lucky8987@163.com>
This commit is contained in:
lucky8987
2024-12-04 01:25:38 +08:00
parent e78d617897
commit 4f4aa40fcf
4 changed files with 9 additions and 14 deletions

View File

@@ -79,8 +79,8 @@ public class FilteringWebHandler implements WebHandler, ApplicationListener<Refr
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 {

View File

@@ -161,8 +161,7 @@ public class RouteDefinitionRouteLocator implements RouteLocator {
// 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);
}

View File

@@ -44,8 +44,7 @@ public class RouteRefreshListener implements ApplicationListener<ApplicationEven
@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
@@ -58,13 +57,11 @@ public class RouteRefreshListener implements ApplicationListener<ApplicationEven
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());
}
}

View File

@@ -74,8 +74,7 @@ public class ProxyExchangeArgumentResolver implements HandlerMethodArgumentResol
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) {