org.conqat.engine.index.shared.FindingDelta Maven / Gradle / Ivy
/*
* Copyright (c) CQSE GmbH
*
* Licensed 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.conqat.engine.index.shared;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
import org.conqat.lib.commons.js_export.ExportToTypeScript;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Result object that wraps a list of added and removed findings */
@ExportToTypeScript
public class FindingDelta implements Serializable {
/** Version used for serialization. */
private static final long serialVersionUID = 1;
/** The name of the JSON property name for {@link #addedFindings}. */
private static final String ADDED_FINDINGS_PROPERTY = "addedFindings";
/** The name of the JSON property name for {@link #findingsInChangedCode}. */
private static final String FINDINGS_IN_CHANGED_CODE_PROPERTY = "findingsInChangedCode";
/** The name of the JSON property name for {@link #removedFindings}. */
private static final String REMOVED_FINDINGS_PROPERTY = "removedFindings";
/** The name of the JSON property name for {@link #findingSummary}. */
private static final String FINDING_SUMMARY_PROPERTY = "findingSummary";
/** The name of the JSON property name for {@link #numberOfAddedFindings}. */
private static final String NUMBER_OF_ADDED_FINDINGS_PROPERTY = "numberOfAddedFindings";
/**
* The name of the JSON property name for
* {@link #numberOfFindingsInChangedCode}.
*/
private static final String NUMBER_OF_FINDINGS_IN_CHANGED_CODE_PROPERTY = "numberOfFindingsInChangedCode";
/** The name of the JSON property name for {@link #numberOfRemovedFindings}. */
private static final String NUMBER_OF_REMOVED_FINDINGS_PROPERTY = "numberOfRemovedFindings";
/** The added findings. May be empty for a numeric only delta. */
@JsonProperty(ADDED_FINDINGS_PROPERTY)
private final List addedFindings;
/** The findings in changed code. */
@JsonProperty(FINDINGS_IN_CHANGED_CODE_PROPERTY)
private final List findingsInChangedCode;
/** The removed findings. */
@JsonProperty(REMOVED_FINDINGS_PROPERTY)
private final List removedFindings;
/** The summary of the finding churn. */
@JsonProperty(FINDING_SUMMARY_PROPERTY)
@Nullable
private final List findingSummary;
/**
* The number of added findings in the delta, regardless of any applied filters.
*/
@JsonProperty(NUMBER_OF_ADDED_FINDINGS_PROPERTY)
private final int numberOfAddedFindings;
/** The number of findings in code changed since the delta, */
@JsonProperty(NUMBER_OF_FINDINGS_IN_CHANGED_CODE_PROPERTY)
private final int numberOfFindingsInChangedCode;
/**
* The number of removed findings in the delta, regardless of any applied
* filters.
*/
@JsonProperty(NUMBER_OF_REMOVED_FINDINGS_PROPERTY)
private final int numberOfRemovedFindings;
/** Creates a {@link FindingDelta} without a summary. */
public static FindingDelta createWithoutSummary(Collection addedFindings,
Collection findingsInChangedCode, Collection removedFindings) {
return create(addedFindings, findingsInChangedCode, removedFindings, null);
}
/** Creates a {@link FindingDelta}. */
public static FindingDelta create(Collection addedFindings,
Collection findingsInChangedCode, Collection removedFindings,
List findingSummary) {
return new FindingDelta(addedFindings, findingsInChangedCode, removedFindings, addedFindings.size(),
findingsInChangedCode.size(), removedFindings.size(), findingSummary);
}
/**
* Creates a {@link FindingDelta} that has only the numbers for the finding
* churn (i.e. without finding lists and summary).
*/
public static FindingDelta createNumericOnly(int numberOfAddedFindings, int numberOfFindingsInChangedCode,
int numberOfRemovedFindings) {
return new FindingDelta(Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
numberOfAddedFindings, numberOfFindingsInChangedCode, numberOfRemovedFindings, null);
}
@JsonCreator
public FindingDelta(@JsonProperty(ADDED_FINDINGS_PROPERTY) Collection addedFindings,
@JsonProperty(FINDINGS_IN_CHANGED_CODE_PROPERTY) Collection findingsInChangedCode,
@JsonProperty(REMOVED_FINDINGS_PROPERTY) Collection removedFindings,
@JsonProperty(NUMBER_OF_ADDED_FINDINGS_PROPERTY) int numberOfAddedFindings,
@JsonProperty(NUMBER_OF_FINDINGS_IN_CHANGED_CODE_PROPERTY) int numberOfFindingsInChangedCode,
@JsonProperty(NUMBER_OF_REMOVED_FINDINGS_PROPERTY) int numberOfRemovedFindings,
@JsonProperty(FINDING_SUMMARY_PROPERTY) List findingSummary) {
this.numberOfAddedFindings = numberOfAddedFindings;
this.numberOfFindingsInChangedCode = numberOfFindingsInChangedCode;
this.numberOfRemovedFindings = numberOfRemovedFindings;
this.addedFindings = new ArrayList<>(addedFindings);
this.findingsInChangedCode = new ArrayList<>(findingsInChangedCode);
this.removedFindings = new ArrayList<>(removedFindings);
this.findingSummary = findingSummary;
}
/** Returns addedFindings. */
public List getAddedFindings() {
return addedFindings;
}
/** Returns findingsInChangedCode. */
public List getFindingsInChangedCode() {
return findingsInChangedCode;
}
/** Returns removedFindings. */
public List getRemovedFindings() {
return removedFindings;
}
/** Returns findingSummary. */
public List getFindingSummary() {
return findingSummary;
}
/** Returns numberOfAddedFindings. */
public int getNumberOfAddedFindings() {
return numberOfAddedFindings;
}
/** Returns numberOfFindingsInChangedCode. */
public int getNumberOfFindingsInChangedCode() {
return numberOfFindingsInChangedCode;
}
/** Returns numberOfRemovedFindings. */
public int getNumberOfRemovedFindings() {
return numberOfRemovedFindings;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy