mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-12-30 20:29:58 +01:00
use value class
This commit is contained in:
@@ -24,7 +24,7 @@ object Implicits {
|
||||
|
||||
implicit def context2ApiJsonFormatContext(implicit context: Context): JsonFormat.Context = JsonFormat.Context(context.baseUrl)
|
||||
|
||||
implicit class RichSeq[A](seq: Seq[A]) {
|
||||
implicit class RichSeq[A](private val seq: Seq[A]) extends AnyVal {
|
||||
|
||||
def splitWith(condition: (A, A) => Boolean): Seq[Seq[A]] = split(seq)(condition)
|
||||
|
||||
@@ -40,7 +40,7 @@ object Implicits {
|
||||
}
|
||||
}
|
||||
|
||||
implicit class RichString(value: String){
|
||||
implicit class RichString(private val value: String) extends AnyVal {
|
||||
def replaceBy(regex: Regex)(replace: Regex.MatchData => Option[String]): String = {
|
||||
val sb = new StringBuilder()
|
||||
var i = 0
|
||||
@@ -63,7 +63,7 @@ object Implicits {
|
||||
}
|
||||
}
|
||||
|
||||
implicit class RichRequest(request: HttpServletRequest){
|
||||
implicit class RichRequest(private val request: HttpServletRequest) extends AnyVal {
|
||||
|
||||
def paths: Array[String] = (request.getRequestURI.substring(request.getContextPath.length + 1) match{
|
||||
case path if path.startsWith("api/v3/repos/") => path.substring(13/* "/api/v3/repos".length */)
|
||||
@@ -84,7 +84,7 @@ object Implicits {
|
||||
}
|
||||
}
|
||||
|
||||
implicit class RichSession(session: HttpSession){
|
||||
implicit class RichSession(private val session: HttpSession) extends AnyVal {
|
||||
def getAndRemove[T](key: String): Option[T] = {
|
||||
val value = session.getAttribute(key).asInstanceOf[T]
|
||||
if(value == null){
|
||||
|
||||
@@ -16,7 +16,7 @@ import scala.collection.mutable.ListBuffer
|
||||
*/
|
||||
object JDBCUtil {
|
||||
|
||||
implicit class RichConnection(conn: Connection){
|
||||
implicit class RichConnection(private val conn: Connection) extends AnyVal {
|
||||
|
||||
def update(sql: String, params: Any*): Int = {
|
||||
execute(sql, params: _*){ stmt =>
|
||||
@@ -214,8 +214,6 @@ object JDBCUtil {
|
||||
tsort(edges).toSeq
|
||||
}
|
||||
|
||||
case class TableDependency(tableName: String, children: Seq[String])
|
||||
|
||||
|
||||
def tsort[A](edges: Traversable[(A, A)]): Iterable[A] = {
|
||||
@tailrec
|
||||
@@ -236,4 +234,6 @@ object JDBCUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private case class TableDependency(tableName: String, children: Seq[String])
|
||||
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
}
|
||||
|
||||
import scala.util.matching.Regex._
|
||||
implicit class RegexReplaceString(s: String) {
|
||||
implicit class RegexReplaceString(private val s: String) extends AnyVal {
|
||||
def replaceAll(pattern: String, replacer: (Match) => String): String = {
|
||||
pattern.r.replaceAllIn(s, (m: Match) => replacer(m).replace("$", "\\$"))
|
||||
}
|
||||
@@ -297,7 +297,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
/**
|
||||
* Implicit conversion to add mkHtml() to Seq[Html].
|
||||
*/
|
||||
implicit class RichHtmlSeq(seq: Seq[Html]) {
|
||||
implicit class RichHtmlSeq(private val seq: Seq[Html]) extends AnyVal {
|
||||
def mkHtml(separator: String) = Html(seq.mkString(separator))
|
||||
def mkHtml(separator: scala.xml.Elem) = Html(seq.mkString(separator.toString))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user