class SimplifiedTimeSeriesLoader {

	@SuppressWarnings("unchecked")
	public static Pair<TimeSeriesDataset2, ClassMapper> loadArffs(final File... arffFiles) throws TimeSeriesLoadingException {
		if (arffFiles == null) {
			throw new IllegalArgumentException("Parameter 'arffFiles' must not be null!");
		}

		final List<double[][]> matrices = new ArrayList<>();
		int[] target = null;
		List<String> classNames = null;

		for (final File arffFile : arffFiles) {
			Object[] tsTargetClassNames = loadTimeSeriesWithTargetFromArffFile(arffFile);

			if (classNames == null && tsTargetClassNames[2] != null) {
				classNames = (List<String>) tsTargetClassNames[2];
			} else {
				// Check whether the same class names are used among all of the time series
				List<String> furtherClassNames = (List<String>) tsTargetClassNames[2];
				if ((classNames != null && furtherClassNames == null) || (furtherClassNames != null && !furtherClassNames.equals(classNames))) {
					throw new TimeSeriesLoadingException("Could not load multivariate time series with different targets. Target values have to be stored in each " + "time series arff file and must be equal!");
				}
			}

			if (target == null) {
				target = (int[]) tsTargetClassNames[1];
			} else {
				// Check whether the same targets are used among all of the time series
				int[] furtherTarget = (int[]) tsTargetClassNames[1];
				if (furtherTarget == null || target.length != furtherTarget.length || !Arrays.equals(target, furtherTarget)) {
					throw new TimeSeriesLoadingException("Could not load multivariate time series with different targets. Target values have to be stored in each " + "time series arff file and must be equal!");
				}
			}

			// Check for same instance length
			if (!matrices.isEmpty() && ((double[][]) tsTargetClassNames[0]).length != matrices.get(0).length) {
				throw new TimeSeriesLoadingException("All time series must have the same first dimensionality (number of instances).");
			}

			matrices.add((double[][]) tsTargetClassNames[0]);
		}
		ClassMapper cm = null;
		if (classNames != null) {
			cm = new ClassMapper(classNames);
		}

		return new Pair<>(new TimeSeriesDataset2(matrices, new ArrayList<>(), target), cm);
	}

	private  SimplifiedTimeSeriesLoader();

}