
tech.mlsql.common.PathFun.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of delta-plus_2.11 Show documentation
Show all versions of delta-plus_2.11 Show documentation
A library based on delta for Spark and [MLSQL](http://www.mlsql.tech).
The newest version!
package tech.mlsql.common
import scala.collection.mutable.ArrayBuffer
/**
* 2019-06-20 WilliamZhu([email protected])
*/
class PathFun(rootPath: String) {
private val buffer = new ArrayBuffer[String]()
buffer += rootPath.stripSuffix("/")
def add(path: String) = {
val cleanPath = path.stripPrefix("/").stripSuffix("/")
if (!cleanPath.isEmpty) {
buffer += cleanPath
}
this
}
def /(path: String) = {
add(path)
}
def toPath = {
buffer.mkString("/")
}
}
object PathFun {
def apply(rootPath: String): PathFun = new PathFun(rootPath)
def joinPath(rootPath: String, paths: String*) = {
val pf = apply(rootPath)
for (arg <- paths) pf.add(arg)
pf.toPath
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy