org.conqat.engine.commons.findings.StatementPathElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of teamscale-commons Show documentation
Show all versions of teamscale-commons Show documentation
Provides common DTOs for Teamscale
The newest version!
/*
* 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.commons.findings;
import java.io.Serializable;
import java.util.Set;
import org.conqat.engine.commons.findings.location.ElementLocation;
import org.conqat.lib.commons.collections.CollectionUtils;
import org.conqat.lib.commons.test.IndexValueClass;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Element of a path of statements that is attached to a finding. See
* {@link DetachedFinding#getStatementPath()} for a more detailed description of its contract and
* usage.
*/
@IndexValueClass(containedInBackup = true)
public class StatementPathElement implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;
private static final String PREDECESSORS_PROPERTY = "predecessors";
private static final String LOCATION_PROPERTY = "location";
private static final String DESCRIPTION_PROPERTY = "description";
/**
* Indices of the predecessors of this path element. The indices refer to the StatementPath (which
* is a list) that this element is a part of.
*/
@JsonProperty(PREDECESSORS_PROPERTY)
private Set predecessors;
/** Location that this path element refers to. */
@JsonProperty(LOCATION_PROPERTY)
private ElementLocation location;
/**
* A user-visible description that explains the role of this path element leading to a finding.
*/
@JsonProperty(DESCRIPTION_PROPERTY)
private String description;
/** Constructor. */
@JsonCreator
public StatementPathElement(@JsonProperty(PREDECESSORS_PROPERTY) Set predecessorPathElements,
@JsonProperty(LOCATION_PROPERTY) ElementLocation location,
@JsonProperty(DESCRIPTION_PROPERTY) String description) {
this.predecessors = predecessorPathElements;
this.location = location;
this.description = description;
}
/** @see #predecessors */
public Set getPredecessorPathElements() {
return CollectionUtils.asUnmodifiable(predecessors);
}
/** @see #location */
public ElementLocation getLocation() {
return location;
}
/** @see #location */
public void setLocation(ElementLocation location) {
this.location = location;
}
/** @see #description */
public String getDescription() {
return description;
}
/** {@inheritDoc} */
@Override
public String toString() {
return getDescription();
}
/**
* Adds the given predecessorId to the predecessors of this StatementPathElement.
*/
public void addPredecessorPathElement(Integer predecessorId) {
this.predecessors.add(predecessorId);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy