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

org.conqat.engine.index.shared.PublicProjectId Maven / Gradle / Ivy

There is a newer version: 2025.1.0-rc2
Show newest version
package org.conqat.engine.index.shared;

import java.util.List;
import java.util.Set;

import org.conqat.lib.commons.collections.CollectionUtils;
import org.conqat.lib.commons.js_export.ExportToTypeScript;

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

/**
 * A public project ID (as opposed to an {@link InternalProjectId}) is a
 * user-facing project ID. The assignment of a public project ID to a project is
 * unambiguous but volatile, i.e. at any given point in time the ID will only
 * refer to a single project, but it may be disassociated with the project and
 * assigned to a different one whenever the user chooses.
 * 
 * A project may have one or more public IDs. The first one of these is called
 * "primary public ID", the other ones "alternative public IDs". The primary
 * public ID is displayed by Teamscale as a canonical ID whenever the user
 * interacts with the project, the alternative IDs are provided for backwards
 * compatibility when a project ID changes but some old references remain (e.g.,
 * URLs still pointing to the former project ID).
 */
@ExportToTypeScript
public class PublicProjectId extends ProjectIdBase {

	private static final long serialVersionUID = 1L;

	@JsonCreator
	public PublicProjectId(@JsonProperty(PROJECT_ID_PROPERTY) String projectId) {
		super(projectId);
		if (isUuidFormat()) {
			throw new IllegalArgumentException("Tried to create a public project ID from \"" + projectId
					+ "\", which does not fit the expected format. Did you supply an internal project ID by mistake?");
		}
	}

	@Override
	public boolean isInternal() {
		return false;
	}

	/** Creates and returns a {@link PublicProjectId} from the given string. */
	public static PublicProjectId of(String projectId) {
		return new PublicProjectId(projectId);
	}

	/**
	 * Creates and returns a {@link PublicProjectId} list from the given strings.
	 */
	public static List of(String... projectIds) {
		return CollectionUtils.map(projectIds, PublicProjectId::new);
	}

	/**
	 * Creates and returns a {@link PublicProjectId} list from the given strings.
	 */
	public static List of(List projectIds) {
		return CollectionUtils.map(projectIds, PublicProjectId::new);
	}

	/**
	 * Creates and returns a {@link PublicProjectId} set from the given strings.
	 */
	public static Set of(Set projectIds) {
		return CollectionUtils.mapToSet(projectIds, PublicProjectId::new);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy