All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.conqat.engine.commons.findings.StatementPathElement Maven / Gradle / Ivy

There is a newer version: 2025.1.0-rc2
Show newest version
/*-------------------------------------------------------------------------+
|                                                                          |
| Copyright (c) 2005-2017 The ConQAT Project                               |
|                                                                          |
| 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.js_export.ExportToTypeScript;

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.
 */

@ExportToTypeScript
public class StatementPathElement implements Serializable {

	/** Serial version UID. */
	private static final long serialVersionUID = 1L;

	/**
	 * 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")
	private Set predecessors;

	/** Location that this path element refers to. */
	@JsonProperty("location")
	private ElementLocation location;

	/**
	 * A user-visible description that explains the role of this path element
	 * leading to a finding.
	 */
	@JsonProperty("description")
	private String description;

	/** Constructor. */
	public StatementPathElement(Set predecessorPathElements, ElementLocation location, 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