Updates to instanceof with variable
Signed-off-by: lucky8987 <lucky8987@163.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user