package com.itstherules.mediacentre.model;
import java.io.File;
import com.itstherules.stream.model.ItemsModel;
public class ItemScalar {
private final String subDirectory;
private final String directory;
public ItemScalar(String directory, String subDirectory) {
this.directory = directory;
this.subDirectory = subDirectory;
}
public File value(String item) {
ItemsModel items = new ItemsModel(directory, subDirectory, extension(item));
for (File file : items.asList()) {
if (item.equals(file.getName())) {
return file;
}
}
throw new RuntimeException();
}
private String extension(String item) {
return item.substring(item.lastIndexOf("."), item.length());
}
}