pkedvessy commented on code in PR #10353:
URL: https://github.com/apache/nifi/pull/10353#discussion_r2401593899


##########
minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-framework-core/src/main/java/org/apache/nifi/minifi/c2/command/DefaultProcessorStateStrategy.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.minifi.c2.command;
+
+import org.apache.nifi.c2.protocol.api.C2OperationState.OperationState;
+import org.apache.nifi.c2.client.service.operation.ProcessorStateStrategy;
+import org.apache.nifi.controller.FlowController;
+import org.apache.nifi.controller.ProcessorNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import static 
org.apache.nifi.c2.protocol.api.C2OperationState.OperationState.FULLY_APPLIED;
+import static 
org.apache.nifi.c2.protocol.api.C2OperationState.OperationState.NOT_APPLIED;
+
+public class DefaultProcessorStateStrategy implements ProcessorStateStrategy {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultProcessorStateStrategy.class);
+
+    private final FlowController flowController;
+
+    public DefaultProcessorStateStrategy(FlowController flowController) {
+        this.flowController = flowController;
+    }
+
+    @Override
+    public OperationState startProcessor(String processorId) {
+        return changeState(processorId, true);
+    }
+
+    @Override
+    public OperationState stopProcessor(String processorId) {
+        return changeState(processorId, false);
+    }
+
+    private OperationState changeState(String processorId, boolean start) {

Review Comment:
   Nitpick:
   Controlling the state transition with a boolean flag works but not well 
readable without checking the body of the method. I can see the reason behind: 
this way you did not duplicate the boilerplate code around the flowController 
calls. I think it would be a bit more readable by passing the state transition 
as a method reference:
   
   Eg.: changeState(processorId, this::star) and changeState(processorId, 
this::stop)
   
   private void start(String processorId, String parentGroupId) ...
   private void stop(String processorId, String parentGroupId) ...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to