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

com.mle.play.io.FileSet.scala Maven / Gradle / Ivy

The newest version!
package com.mle.play.io

import com.mle.file.FileUtilities
import play.api.libs.json.Format

/**
 * @author Michael
 */
abstract class FileSet[T](file: String)(implicit format: Format[T])
  extends FileBackedSet[T](FileUtilities pathTo file) with LoggingList[T] {
  protected def id(elem: T): String

  def areSame(first: T, second: T) = id(first) == id(second)

  override def contains(elem: T, others: Seq[T]): Boolean = others.exists(areSame(elem, _))

  override def filterNot(elem: T, others: Seq[T]): Seq[T] = others.filterNot(areSame(elem, _))

  def withID(elemID: String): Option[T] = get().find(e => id(e) == elemID)

  def removeID(id: String) = withID(id).foreach(remove)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy