本文整理汇总了Scala中java.util.Set类的典型用法代码示例。如果您正苦于以下问题:Scala Set类的具体用法?Scala Set怎么用?Scala Set使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Set类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: TravisCommand
//设置package包名称以及导入依赖的类
package com.atomist.rug.commands.travis
import com.atomist.rug.kind.service.ServicesMutableView
import com.atomist.rug.kind.travis.{RealTravisEndpoints, TravisAPIEndpoint, TravisEndpoints}
import com.atomist.rug.spi.Command
import org.springframework.http.HttpHeaders
import java.util.{Collections, Set}
class TravisCommand extends Command[ServicesMutableView] {
override def nodeTypes: Set[String] = Collections.singleton("Services")
override def name: String = "travis"
override def invokeOn(treeNode: ServicesMutableView): AnyRef = {
new TravisOperations(new RealTravisEndpoints)
}
}
class TravisOperations(travisEndpoints: TravisEndpoints) {
def restartBuild(buildId: Int, org: String, token: String): TravisStatus = {
val api: TravisAPIEndpoint = TravisAPIEndpoint.stringToTravisEndpoint(org)
val travisToken: String = travisEndpoints.postAuthGitHub(api, token)
val headers: HttpHeaders = TravisEndpoints.authHeaders(api, travisToken)
try {
travisEndpoints.postRestartBuild(api, headers, buildId)
new TravisStatus(true, s"Successfully restarted build `${buildId}` on Travis CI")
}
catch {
case e: Exception => new TravisStatus(false, e.getMessage)
}
}
}
case class TravisStatus(success: Boolean = true, message: String = "")
示例2: Dynomite
//设置package包名称以及导入依赖的类
package com.advancedspark.serving.spark
import com.netflix.dyno.jedis._
import com.netflix.dyno.connectionpool.Host
import com.netflix.dyno.connectionpool.HostSupplier
import com.netflix.dyno.connectionpool.TokenMapSupplier
import com.netflix.dyno.connectionpool.impl.lb.HostToken
import com.netflix.dyno.connectionpool.exception.DynoException
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl
import com.netflix.dyno.connectionpool.impl.ConnectionContextImpl
import com.netflix.dyno.connectionpool.impl.OperationResultImpl
import com.netflix.dyno.connectionpool.impl.utils.ZipUtils
import scala.collection.JavaConversions._
import java.util.Collections
import java.util.Collection
import java.util.Set
import java.util.List
object Dynomite {
val localhostHost = new Host("127.0.0.1", Host.Status.Up)
val localhostToken = new HostToken(100000L, localhostHost)
val localhostHostSupplier = new HostSupplier() {
@Override
def getHosts(): Collection[Host] = {
Collections.singletonList(localhostHost)
}
}
val localhostTokenMapSupplier = new TokenMapSupplier() {
@Override
def getTokens(activeHosts: Set[Host]): List[HostToken] = {
Collections.singletonList(localhostToken)
}
@Override
def getTokenForHost(host: Host, activeHosts: Set[Host]): HostToken = {
return localhostToken
}
}
val redisPort = 6379
val client = new DynoJedisClient.Builder()
.withApplicationName("pipeline")
.withDynomiteClusterName("pipeline-dynomite")
.withHostSupplier(localhostHostSupplier)
.withCPConfig(new ConnectionPoolConfigurationImpl("localhostTokenMapSupplier")
.withTokenSupplier(localhostTokenMapSupplier))
.withPort(redisPort)
.build()
}