package de.uka.ipd.sdq.beagle.core;

import de.uka.ipd.sdq.beagle.core.facade.BeagleConfiguration;
import de.uka.ipd.sdq.beagle.core.facade.SourceCodeFileProvider;

import org.apache.commons.lang3.Validate;

import java.io.Serializable;
import java.nio.charset.Charset;

/**
 * Holds information about the project under analysis. Objects of this class are
 * immutable.
 *
 * @author Roman Langrehr
 */
public class ProjectInformation implements Serializable {

	/**
	 * See {@link Serializable}.
	 */
	private static final long serialVersionUID = 2451089669559562551L;

	/**
	 * The timeout to be used. [-2 → adaptive timeout] [-1 → no timeout] [≥ 0 → timeout in
	 * seconds]
	 */
	private final int timeout;

	/**
	 * The provider of the source files to be analysed.
	 */
	private final SourceCodeFileProvider fileProvider;

	/**
	 * The class path containing everything needed to compile the project.
	 */
	private final String buildPath;

	/**
	 * The charset used for all files in the project.
	 */
	private final Charset charset;

	/**
	 * Creates a new Project Information.
	 *
	 * @param timeout The timeout to be used.
	 *
	 *            <table> <caption>timeout value description</caption>
	 *
	 *            <tr><td>{@link BeagleConfiguration#ADAPTIVE_TIMEOUT}</td><td>Beagle will
	 *            use a timeout that adapts to the quality of the analysis’ findings in
	 *            the past.</td>
	 *
	 *            <tr><td>{@link BeagleConfiguration#NO_TIMEOUT}</td><td>no timeout will
	 *            be used</td>
	 *
	 *            <tr><td>{@code ≥ 0}</td><td>the given value will be used as a fixed
	 *            timeout in seconds</td>
	 *
	 *            </table>
	 * @param fileProvider The provider of the source files to be analysed.
	 * @param buildPath The class path containing everything needed to compile the
	 *            project.
	 * @param charset The charset used for all files in the project. May be {@code null},
	 *            in which case {@link Charset#defaultCharset()} will be used.
	 */
	public ProjectInformation(final int timeout, final SourceCodeFileProvider fileProvider, final String buildPath,
		final Charset charset) {
		Validate.notNull(fileProvider);
		Validate.notNull(buildPath);

		this.timeout = timeout;
		this.fileProvider = fileProvider;
		this.charset = charset == null ? Charset.defaultCharset() : charset;
		this.buildPath = buildPath;
	}

	/**
	 * Queries the project’s build path.
	 *
	 * @return The class path containing everything needed to compile the project. Will
	 *         never be {@code null}.
	 */
	public String getBuildPath() {
		return this.buildPath;
	}

	/**
	 * Queries the project’s charset.
	 *
	 * @return The charset used for all files in the project. Will never be {@code null}.
	 */
	public Charset getCharset() {
		return this.charset;
	}

	/**
	 * Returns the timeout to be used. The timeout describes the minimum time Beagle shall
	 * keep trying to find results while no perfect results were found.
	 *
	 * <table> <caption>timeout value description</caption>
	 *
	 * <tr><td>{@link BeagleConfiguration#ADAPTIVE_TIMEOUT}</td><td>Beagle will use a
	 * timeout that adapts to the quality of the analysis’ findings in the past.</td>
	 *
	 * <tr><td>{@link BeagleConfiguration#NO_TIMEOUT}</td><td>no timeout will be used</td>
	 *
	 * <tr><td>{@code ≥ 0}</td><td>the given value will be used as a fixed timeout in
	 * seconds</td>
	 *
	 * </table>
	 *
	 * @return The timeout that will be used by Beagle.
	 */
	public int getTimeout() {
		return this.timeout;
	}

	/**
	 * Queries the provider responsible to get the source files Beagle shall analyse.
	 *
	 *
	 * @return The provider of source files.
	 */
	public SourceCodeFileProvider getFileProvider() {
		return this.fileProvider;
	}
}

@@ -262,16 +262,64 @@
 Charset;
+%0Aimport java.util.HashSet;%0Aimport java.util.Set;
 %0A%0A/**%0A *
@@ -1074,24 +1074,166 @@
 t charset;%0A%0A
+%09/**%0A%09 * The configurations defining how to launch the measured software.%0A%09 */%0A%09private final Set%3CLaunchConfiguration%3E launchConfigurations;%0A%0A
 %09/**%0A%09 * Cre
@@ -2198,24 +2198,227 @@
 ll be used.%0A
+%09 * @param launchConfigurations The configurations defining how to launch the measured%0A%09 *            software. Must not be %7B@code null%7D, must not contain %7B@code null%7D, must%0A%09 *            not be empty.%0A
 %09 */%0A%09public
@@ -2546,16 +2546,69 @@
  charset
+, final Set%3CLaunchConfiguration%3E launchConfigurations
 ) %7B%0A%09%09Va
@@ -2667,16 +2667,163 @@
 ldPath);
+%0A%09%09Validate.noNullElements(launchConfigurations);%0A%09%09Validate.isTrue(!launchConfigurations.isEmpty(), %22The launch configurations may not be empty%22);
 %0A%0A%09%09this
@@ -2971,32 +2971,99 @@
 th = buildPath;%0A
+%09%09this.launchConfigurations = new HashSet%3C%3E(launchConfigurations);%0A
 %09%7D%0A%0A%09/**%0A%09 * Que
@@ -4423,11 +4423,349 @@
 ider;%0A%09%7D
+%0A%0A%09/**%0A%09 * Queries the configurations defining how to launch the measured software.%0A%09 *%0A%09 * @return The project%E2%80%99s launch configurations. Will neither be %7B@code null%7D, nor%0A%09 *         contain %7B@code null%7D, nor be empty.%0A%09 */%0A%09public Set%3CLaunchConfiguration%3E getLaunchConfigurations() %7B%0A%09%09return new HashSet%3C%3E(this.launchConfigurations);%0A%09%7D
 %0A%7D%0A

Put the LaunchConfigurations on the ProjectInformation