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

org.conqat.engine.commons.findings.location.QualifiedNameLocation Maven / Gradle / Ivy

/*-------------------------------------------------------------------------+
|                                                                          |
| Copyright 2005-2011 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.location;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.conqat.lib.commons.assertion.CCSMAssert;
import org.conqat.lib.commons.js_export.ExportToTypeScript;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Location identified by a qualified name, which usually is some kind of path
 * expression.
 */
@ExportToTypeScript
public class QualifiedNameLocation extends ElementLocation {

	/** Version used for serialization. */
	private static final long serialVersionUID = 1;

	/** The name of the JSON property name for {@link #qualifiedName}. */
	private static final String QUALIFIED_NAME_PROPERTY = "qualifiedName";

	/** The name of the JSON property name for {@link #abbreviated}. */
	private static final String ABBREVIATED_PROPERTY = "abbreviated";

	/** The name of the JSON property name for {@link #signalNames}. */
	private static final String SIGNAL_NAMES_PROPERTY = "signalNames";

	/** The qualified name. */
	@JsonProperty(QUALIFIED_NAME_PROPERTY)
	private final String qualifiedName;

	/**
	 * Indicates whether this is abbreviated, i.e. the qualified name is not
	 * expanded to full depth (e.g. because the reference can not be fully
	 * resolved).
	 */
	@JsonProperty(ABBREVIATED_PROPERTY)
	private final boolean abbreviated;

	/** List of signal full names that are going into the location. */
	@JsonProperty(SIGNAL_NAMES_PROPERTY)
	private final List signalNames;

	public QualifiedNameLocation(String qualifiedName, String location, String uniformPath) {
		this(qualifiedName, location, uniformPath, false);
	}

	public QualifiedNameLocation(String qualifiedName, String location, String uniformPath, boolean abbreviated) {
		this(qualifiedName, location, uniformPath, abbreviated, Collections.emptyList());
	}

	@JsonCreator
	public QualifiedNameLocation(@JsonProperty(QUALIFIED_NAME_PROPERTY) String qualifiedName,
			@JsonProperty(LOCATION_PROPERTY) String location, @JsonProperty(UNIFORM_PATH_PROPERTY) String uniformPath,
			@JsonProperty(ABBREVIATED_PROPERTY) boolean abbreviated,
			@JsonProperty(SIGNAL_NAMES_PROPERTY) List signalNames) {
		super(location, uniformPath);
		CCSMAssert.isNotNull(qualifiedName);
		this.qualifiedName = qualifiedName;
		this.abbreviated = abbreviated;
		this.signalNames = new ArrayList<>(signalNames);
	}

	/** Returns the qualified name. */
	public String getQualifiedName() {
		return qualifiedName;
	}

	@Override
	public String toLocationString() {
		return super.toLocationString() + ":" + qualifiedName;
	}

	/** @see #abbreviated */
	public boolean isAbbreviated() {
		return abbreviated;
	}

	/** @see #signalNames */
	public List getSignalNames() {
		return signalNames;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy