当前位置: 首页>>代码示例>>Scala>>正文


Scala Collection类代码示例

本文整理汇总了Scala中java.util.Collection的典型用法代码示例。如果您正苦于以下问题:Scala Collection类的具体用法?Scala Collection怎么用?Scala Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Collection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: SkysailAuthorizationInfo

//设置package包名称以及导入依赖的类
package io.skysail.um.shiro.authorization

import org.apache.shiro.authz.AuthorizationInfo
import io.skysail.core.um.domain.SkysailUser
import org.apache.shiro.authz.SimpleAuthorizationInfo
import java.util.Collection
import org.apache.shiro.authz.Permission
import scala.collection.JavaConverters._

class SkysailAuthorizationInfo(user: SkysailUser) extends AuthorizationInfo {

  val authInfo = new SimpleAuthorizationInfo();
  val roles = scala.collection.mutable.Set[String]()
  
  user.getRoles.foreach(r => roles.add(r.name));
  authInfo.setRoles(roles.asJava);

  override def getStringPermissions(): Collection[String] = {
    return authInfo.getStringPermissions();
  }

  override def getRoles(): Collection[String] = {
    return authInfo.getRoles();
  }

  override def getObjectPermissions(): Collection[Permission] = {
    return authInfo.getObjectPermissions();
  }
} 
开发者ID:evandor,项目名称:skysail-um,代码行数:30,代码来源:SkysailAuthorizationInfo.scala

示例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()
} 
开发者ID:frankiegu,项目名称:serve.ml,代码行数:53,代码来源:Dynomite.scala

示例3: FieldModel

//设置package包名称以及导入依赖的类
package io.skysail.core.model

import java.lang.reflect.Field
import java.lang.reflect.Type
import java.util.Collection
import io.skysail.core.restlet.utils.ScalaReflectionUtils

case class FieldModel(val f: java.lang.reflect.Field) {
  
  require(f != null, "you must provide a non-null field to construct a FieldModel")

  val name = f.getName
  
  //def getInputType(): String = f.getAnnotation(classOf[io.skysail.core.html.Field]).inputType().name();

  def isMandatory(): Boolean = {
    val notNullAnnotation = f.getAnnotation(classOf[javax.validation.constraints.NotNull]);
    if (notNullAnnotation != null) {
      return true;
    }
    val sizeAnnotation = f.getAnnotation(classOf[javax.validation.constraints.Size]);
    if (sizeAnnotation != null) {
      if (sizeAnnotation.min() > 0) {
        return true;
      }
    }
    return false;
  }
  
  //override def toString() = s"""${this.getClass.getSimpleName}(inputType: $getInputType, mandatory: $isMandatory)"""

  private def getEntityType() = {
    if (classOf[Collection[_]].isAssignableFrom(f.getType())) 
      ScalaReflectionUtils.getParameterizedType(f);
    else
      null
  }
} 
开发者ID:evandor,项目名称:skysail-core,代码行数:39,代码来源:FieldModel.scala


注:本文中的java.util.Collection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。