本文整理汇总了Scala中java.util.UUID.randomUUID类的典型用法代码示例。如果您正苦于以下问题:Scala randomUUID类的具体用法?Scala randomUUID怎么用?Scala randomUUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了randomUUID类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Misc
//设置package包名称以及导入依赖的类
package sqlpt.util
import java.util.UUID.randomUUID
import sqlpt.ast.expressions.{Selection, Table}
import sqlpt.ast.statements._, Statements._
object Misc extends Insertion.Implicits {
def withTempTable[Cols <: Product, R]
(selection: Selection[Cols])(action: (=> Table[Cols]) => Statements): Statements = {
val uniqueTempTableName =
"sqlpt_temp_table_" + randomUUID
val tempTable = Table(uniqueTempTableName, selection.cols)
statements(
// TODO: There may be existing code in tests to generate table DDL from `Table` instances.
StringStatement(s"""
|CREATE TALBE $uniqueTempTableName
|ROW FORMAT DELIMITED FIELDS
|TERMINATED BY '|'
|STORED AS TEXTFILE
""".stripMargin),
tempTable.insert(selection),
action(tempTable),
StringStatement(s"""
|DROP TABLE IF EXISTS $uniqueTempTableName
""".stripMargin)
)
}
}
示例2: RadioAnalyzer
//设置package包名称以及导入依赖的类
package com.microsoft.partnercatalyst.fortis.spark.analyzer
import java.time.Instant.now
import java.util.UUID.randomUUID
import com.microsoft.partnercatalyst.fortis.spark.sources.streamwrappers.radio.RadioTranscription
import com.microsoft.partnercatalyst.fortis.spark.transforms.image.ImageAnalyzer
@SerialVersionUID(100L)
class RadioAnalyzer extends Analyzer[RadioTranscription] with Serializable
with AnalysisDefaults.EnableAll[RadioTranscription] {
override def toSchema(item: RadioTranscription, locationFetcher: LocationFetcher, imageAnalyzer: ImageAnalyzer): ExtendedDetails[RadioTranscription] = {
ExtendedDetails(
eventid = randomUUID().toString,
eventtime = now.getEpochSecond,
externalsourceid = item.radioUrl,
body = item.text,
title = "",
pipelinekey = "Radio",
sourceurl = item.radioUrl,
original = item
)
}
}
示例3: EventIdFilter
//设置package包名称以及导入依赖的类
package uk.co.telegraph.utils.server.filters
import java.util.UUID.randomUUID
import javax.inject.{Inject, Singleton}
import akka.stream.Materializer
import play.api.mvc._
import scala.concurrent.Future
import EventIdFilter._
@Singleton
class EventIdFilter @Inject()(implicit val mat:Materializer) extends Filter{
override def apply(f: (RequestHeader) => Future[Result])(request: RequestHeader): Future[Result] = {
if ( request.headers.get(EventIdHeader).isDefined ){
return f(request)
}
val newHeaders = request.headers.add((EventIdHeader, randomUUID().toString))
f(request.withHeaders( newHeaders ))
}
}
object EventIdFilter{
val EventIdHeader = "x-event-id"
}
示例4: CompanyController
//设置package包名称以及导入依赖的类
package controllers
import java.util.UUID.randomUUID
import javax.inject.Singleton
import play.api.libs.json._
import play.api.mvc._
import scala.collection.mutable.ListBuffer
@Singleton
class CompanyController extends Controller {
case class Company(id: Option[String], name: String)
var companies = new ListBuffer[Company]();
// bootstrap data
companies += Company(Option(randomUUID.toString), "Taco Bell")
companies += Company(Option(randomUUID.toString), "Office Max")
companies += Company(Option(randomUUID.toString), "Rueben's Brews")
implicit val companyWrites = Json.writes[Company]
implicit val companyReads = Json.reads[Company]
def listCompanies = Action {
val json = Json.toJson(companies)
Ok(json)
}
def addCompany = Action { request =>
val json = request.body.asJson.get
val companyIn = json.as[Company]
if (companies.find(_.name == companyIn.name).isDefined) {
BadRequest("company named " + companyIn.name + " already exists")
}else if (companyIn.id.isDefined) {
BadRequest("id must not be set for new entry")
} else {
var company = Company(Option(randomUUID.toString),companyIn.name)
companies += company
Ok(Json.toJson(company))
}
}
}
示例5: ApiSchema
//设置package包名称以及导入依赖的类
package api.schema
import sjsonnew.JsonFormat
import sjsonnew.support.scalajson.unsafe.{ Converter, PrettyPrinter }
import scala.collection.immutable.Map
import java.util.UUID.randomUUID
import org.joda.time.DateTime
import api.schema.codec.CustomProtocol._
object ApiSchema {
def main(args: Array[String]): Unit = {
val id = randomUUID().toString
val requestObject = Request(
domain = Domain.activity,
result = Map(
"id" -> id,
"activity" -> Activity.follow.toString
)
)
val responseObject = Response(
method = Method.POST,
action = Action.success,
domain = Domain.activity,
result = Map(
"id" -> id,
"activity" -> Activity.followed.toString
),
timestamp = DateTime.now.toString
)
val response = PrettyPrinter(
Converter.toJsonUnsafe(responseObject)
)
printf("Request => %s\n", requestObject)
printf("Response => %s\n", response)
}
}