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

giant.zenith_2.11.0.3.0.source-code.Extensions.scala Maven / Gradle / Ivy

There is a newer version: 0.4.5
Show newest version
/**
 *   __________            .__  __  .__
 *   \____    /____   ____ |__|/  |_|  |__
 *     /     // __ \ /    \|  \   __\  |  \
 *    /     /\  ___/|   |  \  ||  | |   Y  \
 *   /_______ \___  >___|  /__||__| |___|  /
 *           \/   \/     \/              \/
 */
package zenith

object Extensions extends StringExtensions with ThrowableExtensions

trait StringExtensions {
  implicit class Implicit (val s: String) {
    def splitCamelCase: String = {
      val a = "(?<=[A-Z])(?=[A-Z][a-z])"
      val b = "(?<=[^A-Z])(?=[A-Z])"
      val c = "(?<=[A-Za-z])(?=[^A-Za-z])"
      s"$a|$b|$c".r.replaceAllIn (s, " ").toLowerCase
    }
  }
}

trait ThrowableExtensions {
  implicit class Implicit (val t: Throwable) {
    def stackTrace: String = {
      import java.io.{PrintWriter, StringWriter}
      val stackTrace = new StringWriter
      t.printStackTrace (new PrintWriter (stackTrace))
      stackTrace.toString
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy