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

com.softicar.platform.common.core.java.classpath.JavaClasspathRootFolder Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.java.classpath;

import com.softicar.platform.common.io.classpath.file.IClasspathFile;
import com.softicar.platform.common.io.classpath.file.PlainClasspathFile;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.stream.Collectors;

/**
 * Represents a root folder on the class path.
 *
 * @author Oliver Richers
 */
public class JavaClasspathRootFolder extends AbstractJavaClasspathRoot {

	private final Collection files;

	public JavaClasspathRootFolder(File file) {

		super(file);

		this.files = new ArrayList<>();
		addFilesDeep(file);
	}

	@Override
	public String toString() {

		return getFile().getAbsolutePath();
	}

	@Override
	public Collection getAllFiles() {

		return files//
			.stream()
			.map(file -> new PlainClasspathFile(getFile(), file))
			.collect(Collectors.toList());
	}

	private void addFilesDeep(File currentFolder) {

		for (File file: currentFolder.listFiles()) {
			if (file.isDirectory()) {
				addFilesDeep(file);
			} else {
				files.add(file);
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy