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

edu.kit.ifv.mobitopp.data.local.FolderValidator Maven / Gradle / Ivy

Go to download

mobiTopp (http://mobitopp.ifv.kit.edu/) is an agent-based travel demand model developed at the Institute for transport studies at the Karlsruhe Institute of Technology (http://www.ifv.kit.edu/english/index.php). Publications about mobiTopp can be found on the project site (http://mobitopp.ifv.kit.edu/28.php).

The newest version!
package edu.kit.ifv.mobitopp.data.local;

import static edu.kit.ifv.mobitopp.util.collections.StreamUtils.warn;

import java.io.File;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class FolderValidator {

	private final File folder;

	public FolderValidator(File folder) {
		super();
		this.folder = folder;
	}

	public void isValid() {
		isNotNull();
		exists();
		isFolder();
	}


	private void isNotNull() {
		if (null == folder) {
			throw warn(new IllegalArgumentException("Folder is not specified in configuration!"), log);
		}
	}

	private void exists() {
		if (!folder.exists()) {
			throw warn(new IllegalArgumentException("Folder is missing: " + folder.getAbsolutePath()), log);
		}
	}
	
	private void isFolder() {
		if (folder.isFile()) {
			throw warn(new IllegalArgumentException("Path does not point to a folder: " + folder.getAbsolutePath()), log);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy