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

com.mle.util.Implicits.scala Maven / Gradle / Ivy

The newest version!
package com.mle.util

import java.util.concurrent.TimeUnit
import java.nio.file.Path
import java.util.Properties
import collection.JavaConversions._

/**
 * @author Mle
 */

object Implicits {
  /**
   * Usage: 5.seconds
   * @param i amount
   * @return the amount along with the given time unit
   */
  implicit def int2timeUnits(i: Int) = new {
    def milliseconds = (i, TimeUnit.MILLISECONDS)

    def seconds = (i, TimeUnit.SECONDS)

    def minutes = (i, TimeUnit.MINUTES)

    def hours = (i, TimeUnit.HOURS)

    def days = (i, TimeUnit.DAYS)
  }

  implicit def code2callable[T](code: => T) = Scheduling.callable(code)

  /**
   * Aliases / to Path.resolve ala sbt
   * @param path this
   * @return path resolve next
   */
  implicit def path2path(path: Path) = new {
    def /(next: String) = path resolve next
  }

  implicit def map2props(map: collection.Map[_ <: AnyRef, _ <: AnyRef]) = new {
    def toProperties = {
      val props = new Properties
      props putAll map
      props
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy