本文整理汇总了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)
)
}
}
开发者ID:pmellati,项目名称:SQLpt,代码行数:35,代码来源:Misc.scala
示例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
)
}
}
开发者ID:CatalystCode,项目名称:project-fortis-spark,代码行数:25,代码来源:RadioAnalyzer.scala
示例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"
}
开发者ID:telegraph,项目名称:tmg-utils,代码行数:29,代码来源:EventIdFilter.scala
示例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))
}
}
}
开发者ID:dknoern,项目名称:resee,代码行数:45,代码来源:CompanyController.scala
示例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)
}
}
开发者ID:dataday,项目名称:sbt-contraband-example,代码行数:44,代码来源:ApiSchema.scala
注:本文中的java.util.UUID.randomUUID类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论