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

validation.FieldPath.scala Maven / Gradle / Ivy

There is a newer version: 0.1.2
Show newest version
package jap
package validation

case class FieldPath(value: List[String]) extends AnyVal {
  def isRoot             = value.isEmpty
  def full: String       = if (isRoot) "root" else value.mkString(".")
  def name: String       = value.lastOption.getOrElse("root")

  def named(name: String): FieldPath = FieldPath(value.dropRight(1) :+ name)
  def ++(path: FieldPath): FieldPath    = FieldPath(value ++ path.value)
  def +(path: String): FieldPath        = FieldPath(value :+ path)

  override def toString: String = full
}

object FieldPath {
  val root                             = FieldPath()
  def apply(value: String*): FieldPath = FieldPath(value.toList)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy