Package com.itstherules.mediacentre.model

Source Code of com.itstherules.mediacentre.model.ItemScalar

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());
  }

}
TOP

Related Classes of com.itstherules.mediacentre.model.ItemScalar

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.