package com.itstherules.stream.model;
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
import com.itstherules.stream.filefilter.ItemsFilter;
public class ItemsModel extends AbstractModel {
private String extensions;
private final String baseDirectory;
private final String currentDirectory;
public ItemsModel(String baseDirectory,String currentDirectory, String extensions) {
this.baseDirectory = baseDirectory;
this.currentDirectory = currentDirectory;
this.extensions = extensions;
}
public String getDirectoryPath() {
return getFullPath(this.baseDirectory) + "/" + nullGuard(currentDirectory);
}
public File get(String fileName) throws FileNotFoundException{
for (File file : asList()) {
if(fileName.equalsIgnoreCase(file.getName())){
return file;
}
}
throw new FileNotFoundException();
}
public FileFilter getFilter() {
return new ItemsFilter(extensions);
}
public String getCurrentDirectory() {
return currentDirectory;
}
public String getBaseDirectory() {
return baseDirectory;
}
}