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

migrate.internal.RelativePath.scala Maven / Gradle / Ivy

There is a newer version: 0.7.2
Show newest version
package migrate.internal

import java.io.File
import java.nio.file.Path
import java.nio.file.Paths

import scala.util.Try

case class RelativePath private (value: String) {
  require(!toPath.isAbsolute, s"$toPath is not relative!")

  def toPath: Path              = Paths.get(value)
  def toFile: File              = new File(value)
  def getName: PathName         = PathName(toPath.getFileName.toString)
  def getParent: RelativePath   = RelativePath(toPath.getParent.toString)
  override def toString: String = value

}

object RelativePath {
  def from(value: String): Try[RelativePath] = Try(RelativePath(value))
  def from(path: Path): Try[RelativePath]    = Try(RelativePath(path.toString))
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy