tpalfy commented on code in PR #7191: URL: https://github.com/apache/nifi/pull/7191#discussion_r1185386337
########## nifi-api/src/main/java/org/apache/nifi/flowanalysis/GroupAnalysisResult.java: ########## @@ -0,0 +1,124 @@ +/* + * 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.flowanalysis; + +import org.apache.nifi.flow.VersionedComponent; + +import java.util.Optional; +import java.util.StringJoiner; + +/** + * Holds information about a {@link FlowAnalysisRule} violation after analyzing (a part of) the flow, represented by a process group. + * One such analysis can result in multiple instances of this class. + */ +public class GroupAnalysisResult extends AbstractAnalysisResult { + private final Optional<VersionedComponent> component; + + private GroupAnalysisResult(String issueId, String message, String explanation) { + this(issueId, message, explanation, Optional.empty()); + } + + private GroupAnalysisResult(VersionedComponent component, String issueId, String message, String explanation) { + this(issueId, message, explanation, Optional.of(component)); + } + + private GroupAnalysisResult(String issueId, String message, String explanation, Optional<VersionedComponent> component) { + super(issueId, message, explanation); + this.component = component; + } + + /** + * Create a new analysis result tied to the currently analyzed process group + * + * @param issueId A rule-defined id that corresponds to a unique type of issue recognized by the rule. + * Newer analysis runs may produce a result with the same issueId in which case the old one will + * be overwritten (or recreated if it is the same in other aspects as well). + * However, if the previous result was disabled the new one will be disabled as well. + * @param message A violation message + * @return a new analysis result instance tied to the currently analyzed process group + */ + public static GroupAnalysisResult newResultForGroup(String issueId, String message) { Review Comment: Here I will add a Builder. There are multiple but limited and specific ways of creating a proper instance. -- 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]
