This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 6cdc5b6fe7 NIFI-14252 Refactored to use enhanced switch several 
framework classes (#9703)
6cdc5b6fe7 is described below

commit 6cdc5b6fe7b291a50a86e01f9d2a240fe92c5c12
Author: dan-s1 <[email protected]>
AuthorDate: Sat Feb 8 13:25:49 2025 -0500

    NIFI-14252 Refactored to use enhanced switch several framework classes 
(#9703)
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../nifi/remote/util/SiteToSiteRestApiClient.java  | 30 +++-----
 .../authorization/resource/ResourceFactory.java    | 57 ++++------------
 .../coordination/node/NodeClusterCoordinator.java  | 39 ++++-------
 .../service/StandardControllerServiceNode.java     | 16 ++---
 .../apache/nifi/groups/StandardProcessGroup.java   | 24 +++----
 .../nifi/controller/StandardFlowService.java       | 13 ++--
 .../clustered/SocketLoadBalancedFlowFileQueue.java | 24 ++-----
 .../apache/nifi/web/StandardNiFiServiceFacade.java | 48 ++++---------
 .../web/StandardNiFiWebConfigurationContext.java   | 79 +++++++++-------------
 9 files changed, 111 insertions(+), 219 deletions(-)

diff --git 
a/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/SiteToSiteRestApiClient.java
 
b/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/SiteToSiteRestApiClient.java
index 217bc2457b..c69def325a 100644
--- 
a/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/SiteToSiteRestApiClient.java
+++ 
b/nifi-commons/nifi-site-to-site-client/src/main/java/org/apache/nifi/remote/util/SiteToSiteRestApiClient.java
@@ -1453,16 +1453,11 @@ public class SiteToSiteRestApiClient implements 
Closeable {
             logger.debug("commitReceivingFlowFiles responseCode={}", 
responseCode);
 
             try (InputStream content = response.getEntity().getContent()) {
-                switch (responseCode) {
-                    case RESPONSE_CODE_OK:
-                        return readResponse(content);
-
-                    case RESPONSE_CODE_BAD_REQUEST:
-                        return readResponse(content);
-
-                    default:
-                        throw handleErrResponse(responseCode, content);
-                }
+                return switch (responseCode) {
+                    case RESPONSE_CODE_OK -> readResponse(content);
+                    case RESPONSE_CODE_BAD_REQUEST -> readResponse(content);
+                    default -> throw handleErrResponse(responseCode, content);
+                };
             }
         }
 
@@ -1483,16 +1478,11 @@ public class SiteToSiteRestApiClient implements 
Closeable {
             logger.debug("commitTransferFlowFiles responseCode={}", 
responseCode);
 
             try (InputStream content = response.getEntity().getContent()) {
-                switch (responseCode) {
-                    case RESPONSE_CODE_OK:
-                        return readResponse(content);
-
-                    case RESPONSE_CODE_BAD_REQUEST:
-                        return readResponse(content);
-
-                    default:
-                        throw handleErrResponse(responseCode, content);
-                }
+                return switch (responseCode) {
+                    case RESPONSE_CODE_OK -> readResponse(content);
+                    case RESPONSE_CODE_BAD_REQUEST -> readResponse(content);
+                    default -> throw handleErrResponse(responseCode, content);
+                };
             }
         }
 
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
index 8947f33f19..7b5f4d84a0 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java
@@ -546,48 +546,21 @@ public final class ResourceFactory {
 
             @Override
             public String getSafeDescription() {
-                final String componentType;
-                switch (resourceType) {
-                    case ControllerService:
-                        componentType = "Controller Service";
-                        break;
-                    case ProcessGroup:
-                        componentType = "Process Group";
-                        break;
-                    case Funnel:
-                        componentType = "Funnel";
-                        break;
-                    case InputPort:
-                        componentType = "Input Port";
-                        break;
-                    case OutputPort:
-                        componentType = "Output Port";
-                        break;
-                    case Processor:
-                        componentType = "Processor";
-                        break;
-                    case RemoteProcessGroup:
-                        componentType = "Remote Process Group";
-                        break;
-                    case ReportingTask:
-                        componentType = "Reporting Task";
-                        break;
-                    case FlowAnalysisRule:
-                        componentType = "Flow Analysis Rule";
-                        break;
-                    case Label:
-                        componentType = "Label";
-                        break;
-                    case ParameterContext:
-                        componentType = "Parameter Context";
-                        break;
-                    case ParameterProvider:
-                        componentType = "Parameter Provider";
-                        break;
-                    default:
-                        componentType = "Component";
-                        break;
-                }
+                final String componentType = switch (resourceType) {
+                    case ControllerService -> "Controller Service";
+                    case ProcessGroup -> "Process Group";
+                    case Funnel -> "Funnel";
+                    case InputPort -> "Input Port";
+                    case OutputPort -> "Output Port";
+                    case Processor -> "Processor";
+                    case RemoteProcessGroup -> "Remote Process Group";
+                    case ReportingTask -> "Reporting Task";
+                    case FlowAnalysisRule -> "Flow Analysis Rule";
+                    case Label -> "Label";
+                    case ParameterContext -> "Parameter Context";
+                    case ParameterProvider -> "Parameter Provider";
+                    default -> "Component";
+                };
                 return componentType + " with ID " + identifier;
             }
         };
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
index 1bbf43d1d6..50beac29ba 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
@@ -595,20 +595,11 @@ public class NodeClusterCoordinator implements 
ClusterCoordinator, ProtocolHandl
         logger.info("{} requested disconnection from cluster due to {}", 
nodeId, explanation == null ? disconnectionCode : explanation);
         updateNodeStatus(new NodeConnectionStatus(nodeId, disconnectionCode, 
explanation), false);
 
-        final Severity severity;
-        switch (disconnectionCode) {
-            case STARTUP_FAILURE:
-            case MISMATCHED_FLOWS:
-            case UNKNOWN:
-                severity = Severity.ERROR;
-                break;
-            case LACK_OF_HEARTBEAT:
-                severity = Severity.WARNING;
-                break;
-            default:
-                severity = Severity.INFO;
-                break;
-        }
+        final Severity severity = switch (disconnectionCode) {
+            case STARTUP_FAILURE, MISMATCHED_FLOWS, UNKNOWN -> Severity.ERROR;
+            case LACK_OF_HEARTBEAT -> Severity.WARNING;
+            default -> Severity.INFO;
+        };
 
         reportEvent(nodeId, severity, "Node disconnected from cluster due to " 
+ explanation);
     }
@@ -1117,17 +1108,17 @@ public class NodeClusterCoordinator implements 
ClusterCoordinator, ProtocolHandl
 
     @Override
     public ProtocolMessage handle(final ProtocolMessage protocolMessage, final 
Set<String> nodeIdentities) throws ProtocolException {
-        switch (protocolMessage.getType()) {
-            case CONNECTION_REQUEST:
-                return handleConnectionRequest((ConnectionRequestMessage) 
protocolMessage, nodeIdentities);
-            case NODE_STATUS_CHANGE:
+        return switch (protocolMessage.getType()) {
+            case CONNECTION_REQUEST ->
+                    handleConnectionRequest((ConnectionRequestMessage) 
protocolMessage, nodeIdentities);
+            case NODE_STATUS_CHANGE -> {
                 handleNodeStatusChange((NodeStatusChangeMessage) 
protocolMessage);
-                return null;
-            case NODE_CONNECTION_STATUS_REQUEST:
-                return handleNodeConnectionStatusRequest();
-            default:
-                throw new ProtocolException("Cannot handle Protocol Message " 
+ protocolMessage + " because it is not of the correct type");
-        }
+                yield null;
+            }
+            case NODE_CONNECTION_STATUS_REQUEST -> 
handleNodeConnectionStatusRequest();
+            default ->
+                    throw new ProtocolException("Cannot handle Protocol 
Message " + protocolMessage + " because it is not of the correct type");
+        };
     }
 
     private NodeConnectionStatusResponseMessage 
handleNodeConnectionStatusRequest() {
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
index edfba0e5c4..8972da8289 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/StandardControllerServiceNode.java
@@ -555,18 +555,14 @@ public class StandardControllerServiceNode extends 
AbstractComponentNode impleme
 
     @Override
     public boolean isValidationNecessary() {
-        switch (getState()) {
-            case DISABLED:
-            case DISABLING:
-                return true;
-            case ENABLING:
+        return switch (getState()) {
+            case DISABLED, DISABLING -> true;
+            case ENABLING ->
                 // If enabling and currently not valid, then we must trigger 
validation to occur. This allows the #enable method
                 // to continue running in the background and complete enabling 
when the service becomes valid.
-                return getValidationStatus() != ValidationStatus.VALID;
-            case ENABLED:
-            default:
-                return false;
-        }
+                    getValidationStatus() != ValidationStatus.VALID;
+            default -> false;
+        };
     }
 
     @Override
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
index 0375642b98..786b8313f7 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java
@@ -620,15 +620,10 @@ public final class StandardProcessGroup implements 
ProcessGroup {
         }
 
         final ScheduledState currentState = 
statelessGroupNode.getCurrentState();
-        switch (currentState) {
-            case RUNNING:
-            case RUN_ONCE:
-            case STARTING:
-            case STOPPING:
-                return StatelessGroupScheduledState.RUNNING;
-            default:
-                return StatelessGroupScheduledState.STOPPED;
-        }
+        return switch (currentState) {
+            case RUNNING, RUN_ONCE, STARTING, STOPPING -> 
StatelessGroupScheduledState.RUNNING;
+            default -> StatelessGroupScheduledState.STOPPED;
+        };
     }
 
     @Override
@@ -638,13 +633,10 @@ public final class StandardProcessGroup implements 
ProcessGroup {
         }
 
         final ScheduledState currentState = 
statelessGroupNode.getDesiredState();
-        switch (currentState) {
-            case RUNNING:
-            case STARTING:
-                return StatelessGroupScheduledState.RUNNING;
-            default:
-                return StatelessGroupScheduledState.STOPPED;
-        }
+        return switch (currentState) {
+            case RUNNING, STARTING -> StatelessGroupScheduledState.RUNNING;
+            default -> StatelessGroupScheduledState.STOPPED;
+        };
     }
 
     @Override
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
index 8e89e6b8be..09f4d38f77 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
@@ -362,15 +362,10 @@ public class StandardFlowService implements FlowService, 
ProtocolHandler {
 
     @Override
     public boolean canHandle(final ProtocolMessage msg) {
-        switch (msg.getType()) {
-            case RECONNECTION_REQUEST:
-            case OFFLOAD_REQUEST:
-            case DISCONNECTION_REQUEST:
-            case FLOW_REQUEST:
-                return true;
-            default:
-                return false;
-        }
+        return switch (msg.getType()) {
+            case RECONNECTION_REQUEST, OFFLOAD_REQUEST, DISCONNECTION_REQUEST, 
FLOW_REQUEST -> true;
+            default -> false;
+        };
     }
 
     @Override
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/SocketLoadBalancedFlowFileQueue.java
 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/SocketLoadBalancedFlowFileQueue.java
index d976dbe736..51d10c957a 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/SocketLoadBalancedFlowFileQueue.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/clustered/SocketLoadBalancedFlowFileQueue.java
@@ -213,23 +213,13 @@ public class SocketLoadBalancedFlowFileQueue extends 
AbstractFlowFileQueue imple
     }
 
     private FlowFilePartitioner 
getPartitionerForLoadBalancingStrategy(LoadBalanceStrategy strategy, String 
partitioningAttribute) {
-        FlowFilePartitioner partitioner;
-        switch (strategy) {
-            case DO_NOT_LOAD_BALANCE:
-                partitioner = new LocalPartitionPartitioner();
-                break;
-            case PARTITION_BY_ATTRIBUTE:
-                partitioner = new 
CorrelationAttributePartitioner(partitioningAttribute);
-                break;
-            case ROUND_ROBIN:
-                partitioner = new RoundRobinPartitioner();
-                break;
-            case SINGLE_NODE:
-                partitioner = new FirstNodePartitioner();
-                break;
-            default:
-                throw new IllegalArgumentException();
-        }
+        FlowFilePartitioner partitioner = switch (strategy) {
+            case DO_NOT_LOAD_BALANCE -> new LocalPartitionPartitioner();
+            case PARTITION_BY_ATTRIBUTE -> new 
CorrelationAttributePartitioner(partitioningAttribute);
+            case ROUND_ROBIN -> new RoundRobinPartitioner();
+            case SINGLE_NODE -> new FirstNodePartitioner();
+            default -> throw new IllegalArgumentException();
+        };
         return partitioner;
     }
 
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index 672e0bde6c..01cd350e66 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -4005,40 +4005,20 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
 
         final Authorizable authorizable;
         try {
-            switch (type) {
-                case PROCESSOR:
-                    authorizable = 
authorizableLookup.getProcessor(sourceId).getAuthorizable();
-                    break;
-                case REPORTING_TASK:
-                    authorizable = 
authorizableLookup.getReportingTask(sourceId).getAuthorizable();
-                    break;
-                case FLOW_ANALYSIS_RULE:
-                    authorizable = 
authorizableLookup.getFlowAnalysisRule(sourceId).getAuthorizable();
-                    break;
-                case PARAMETER_PROVIDER:
-                    authorizable = 
authorizableLookup.getParameterProvider(sourceId).getAuthorizable();
-                    break;
-                case CONTROLLER_SERVICE:
-                    authorizable = 
authorizableLookup.getControllerService(sourceId).getAuthorizable();
-                    break;
-                case FLOW_CONTROLLER:
-                    authorizable = controllerFacade;
-                    break;
-                case INPUT_PORT:
-                    authorizable = authorizableLookup.getInputPort(sourceId);
-                    break;
-                case OUTPUT_PORT:
-                    authorizable = authorizableLookup.getOutputPort(sourceId);
-                    break;
-                case REMOTE_PROCESS_GROUP:
-                    authorizable = 
authorizableLookup.getRemoteProcessGroup(sourceId);
-                    break;
-                case PROCESS_GROUP:
-                    authorizable = 
authorizableLookup.getProcessGroup(sourceId).getAuthorizable();
-                    break;
-                default:
-                    throw new 
WebApplicationException(Response.serverError().entity("An unexpected type of 
component is the source of this bulletin.").build());
-            }
+            authorizable = switch (type) {
+                case PROCESSOR -> 
authorizableLookup.getProcessor(sourceId).getAuthorizable();
+                case REPORTING_TASK -> 
authorizableLookup.getReportingTask(sourceId).getAuthorizable();
+                case FLOW_ANALYSIS_RULE -> 
authorizableLookup.getFlowAnalysisRule(sourceId).getAuthorizable();
+                case PARAMETER_PROVIDER -> 
authorizableLookup.getParameterProvider(sourceId).getAuthorizable();
+                case CONTROLLER_SERVICE -> 
authorizableLookup.getControllerService(sourceId).getAuthorizable();
+                case FLOW_CONTROLLER -> controllerFacade;
+                case INPUT_PORT -> authorizableLookup.getInputPort(sourceId);
+                case OUTPUT_PORT -> authorizableLookup.getOutputPort(sourceId);
+                case REMOTE_PROCESS_GROUP -> 
authorizableLookup.getRemoteProcessGroup(sourceId);
+                case PROCESS_GROUP -> 
authorizableLookup.getProcessGroup(sourceId).getAuthorizable();
+                default ->
+                        throw new 
WebApplicationException(Response.serverError().entity("An unexpected type of 
component is the source of this bulletin.").build());
+            };
         } catch (final ResourceNotFoundException e) {
             // if the underlying component is gone, disallow
             return false;
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
index f3ae70a04f..0d6208adac 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
@@ -124,53 +124,53 @@ public class StandardNiFiWebConfigurationContext 
implements NiFiWebConfiguration
             throw new IllegalArgumentException("The UI extension type must be 
specified.");
         }
 
-        Component componentType = null;
-        switch (requestContext.getExtensionType()) {
-            case ProcessorConfiguration:
+        Component componentType = switch (requestContext.getExtensionType()) {
+            case ProcessorConfiguration -> {
                 // authorize access
                 serviceFacade.authorizeAccess(lookup -> {
                     final Authorizable authorizable = 
lookup.getProcessor(requestContext.getId()).getAuthorizable();
                     authorizable.authorize(authorizer, RequestAction.WRITE, 
NiFiUserUtils.getNiFiUser());
                 });
 
-                componentType = Component.Processor;
-                break;
-            case ControllerServiceConfiguration:
+                yield Component.Processor;
+            }
+            case ControllerServiceConfiguration -> {
                 // authorize access
                 serviceFacade.authorizeAccess(lookup -> {
                     final Authorizable authorizable = 
lookup.getControllerService(requestContext.getId()).getAuthorizable();
                     authorizable.authorize(authorizer, RequestAction.WRITE, 
NiFiUserUtils.getNiFiUser());
                 });
 
-                componentType = Component.ControllerService;
-                break;
-            case ReportingTaskConfiguration:
+                yield Component.ControllerService;
+            }
+            case ReportingTaskConfiguration -> {
                 // authorize access
                 serviceFacade.authorizeAccess(lookup -> {
                     final Authorizable authorizable = 
lookup.getReportingTask(requestContext.getId()).getAuthorizable();
                     authorizable.authorize(authorizer, RequestAction.WRITE, 
NiFiUserUtils.getNiFiUser());
                 });
 
-                componentType = Component.ReportingTask;
-                break;
-            case ParameterProviderConfiguration:
+                yield Component.ReportingTask;
+            }
+            case ParameterProviderConfiguration -> {
                 // authorize access
                 serviceFacade.authorizeAccess(lookup -> {
                     final Authorizable authorizable = 
lookup.getParameterProvider(requestContext.getId()).getAuthorizable();
                     authorizable.authorize(authorizer, RequestAction.WRITE, 
NiFiUserUtils.getNiFiUser());
                 });
 
-                componentType = Component.ParameterProvider;
-                break;
-            case FlowRegistryClientConfiguration:
+                yield Component.ParameterProvider;
+            }
+            case FlowRegistryClientConfiguration -> {
                 // authorize access
                 serviceFacade.authorizeAccess(lookup -> {
                     final Authorizable authorizable = 
lookup.getFlowRegistryClient(requestContext.getId()).getAuthorizable();
                     authorizable.authorize(authorizer, RequestAction.WRITE, 
NiFiUserUtils.getNiFiUser());
                 });
-                componentType = Component.FlowRegistryClient;
-                break;
-        }
+                yield Component.FlowRegistryClient;
+            }
+            default -> null;
+        };
 
         if (componentType == null) {
             throw new IllegalArgumentException("UI extension type must support 
Processor, ControllerService, or ReportingTask configuration.");
@@ -232,23 +232,14 @@ public class StandardNiFiWebConfigurationContext 
implements NiFiWebConfiguration
         }
 
         // get the component facade for interacting directly with that type of 
object
-        ComponentFacade componentFacade = null;
-        switch (requestContext.getExtensionType()) {
-            case ProcessorConfiguration:
-                componentFacade = new ProcessorFacade();
-                break;
-            case ControllerServiceConfiguration:
-                componentFacade = new ControllerServiceFacade();
-                break;
-            case ReportingTaskConfiguration:
-                componentFacade = new ReportingTaskFacade();
-                break;
-            case ParameterProviderConfiguration:
-                componentFacade = new ParameterProviderFacade();
-                break;
-            case FlowRegistryClientConfiguration:
-                componentFacade = new FlowRegistryClientFacade();
-        }
+        ComponentFacade componentFacade = switch 
(requestContext.getExtensionType()) {
+            case ProcessorConfiguration -> new ProcessorFacade();
+            case ControllerServiceConfiguration -> new 
ControllerServiceFacade();
+            case ReportingTaskConfiguration -> new ReportingTaskFacade();
+            case ParameterProviderConfiguration -> new 
ParameterProviderFacade();
+            case FlowRegistryClientConfiguration -> new 
FlowRegistryClientFacade();
+            default -> null;
+        };
 
         if (componentFacade == null) {
             throw new IllegalArgumentException("UI extension type must support 
Processor, ControllerService, or ReportingTask configuration.");
@@ -273,18 +264,12 @@ public class StandardNiFiWebConfigurationContext 
implements NiFiWebConfiguration
         }
 
         // get the component facade for interacting directly with that type of 
object
-        ComponentFacade componentFacade = null;
-        switch (requestContext.getExtensionType()) {
-            case ProcessorConfiguration:
-                componentFacade = new ProcessorFacade();
-                break;
-            case ControllerServiceConfiguration:
-                componentFacade = new ControllerServiceFacade();
-                break;
-            case ReportingTaskConfiguration:
-                componentFacade = new ReportingTaskFacade();
-                break;
-        }
+        ComponentFacade componentFacade = switch 
(requestContext.getExtensionType()) {
+            case ProcessorConfiguration -> new ProcessorFacade();
+            case ControllerServiceConfiguration -> new 
ControllerServiceFacade();
+            case ReportingTaskConfiguration -> new ReportingTaskFacade();
+            default -> null;
+        };
 
         if (componentFacade == null) {
             throw new IllegalArgumentException("UI extension type must support 
Processor, ControllerService, or ReportingTask configuration.");

Reply via email to