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


Scala Nullable类代码示例

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


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

示例1: BakedModelFrame

//设置package包名称以及导入依赖的类
package intricateengineers.intricatemachinery.api.client

import javax.annotation.Nullable

import intricateengineers.intricatemachinery.api.model.IMBakedModel
import intricateengineers.intricatemachinery.api.module.{FrameModel, FrameProperty, MachineryFrame}
import mcp.MethodsReturnNonnullByDefault
import net.minecraft.block.state.IBlockState
import net.minecraft.client.renderer.block.model._
import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.util.EnumFacing
import net.minecraftforge.common.property.IExtendedBlockState

object BakedModelFrame extends IMBakedModel {

  def initTextures(): Unit = {
    FrameModel.boxes.foreach(_.initTextures())
  }

  @MethodsReturnNonnullByDefault
  def getQuads(@Nullable state: IBlockState, @Nullable side: EnumFacing, rand: Long): java.util.List[BakedQuad] = {
    if (side != null) {
      return new java.util.ArrayList[BakedQuad]
    }
    state match {
      case extendedState: IExtendedBlockState =>
        val frame: MachineryFrame = extendedState.getValue(FrameProperty)
        if (frame != null) {
          return frame.quadCache()
        }
    }
    new java.util.ArrayList[BakedQuad]
  }

  def isAmbientOcclusion: Boolean = false

  def isGui3d: Boolean = false

  def isBuiltInRenderer: Boolean = false

  def getParticleTexture: TextureAtlasSprite = null

  def getItemCameraTransforms: ItemCameraTransforms = null

  def getOverrides: ItemOverrideList = null
} 
开发者ID:IntricateEngineers,项目名称:IntricateMachinery,代码行数:47,代码来源:BakedModelFrame.scala

示例2: getId

//设置package包名称以及导入依赖的类
package orm.elasticsearch
import java.{util => ju}
import javax.annotation.Nullable

import org.elasticsearch.action.get.GetResponse
import org.elasticsearch.search.highlight.HighlightField
import org.elasticsearch.search.{SearchHit, SearchHitField}


trait EsClassData {
  @Nullable def getId: String
  @Nullable def get(field: String): AnyRef
  @Nullable def getHighlightedField(field: String): HighlightField
  def isFieldHighlighted(field: String): Boolean
  def score: Option[Float]
}

class EsClassHitData(val hit: SearchHit) extends EsClassData {
  val map = hit.sourceAsMap()
  val hf = hit.highlightFields()
  @Nullable override def getId: String = hit.getId
  @Nullable override def get(field: String): AnyRef = map.get(field)
  @Nullable override def getHighlightedField(field: String): HighlightField = hf.get(field)
  override def isFieldHighlighted(field: String): Boolean = hf.containsKey(field)
  override def score: Option[Float] = Some(hit.score())
}

class EsClassHitFieldsData(val hit: SearchHit) extends EsClassData {
  val fields: ju.Map[String, SearchHitField] = hit.fields()
  val hf = hit.highlightFields()
  @Nullable override def getId: String = hit.getId
  @Nullable override def get(field: String): AnyRef = fields.get(field).value()
  @Nullable override def getHighlightedField(field: String): HighlightField = hf.get(field)
  override def isFieldHighlighted(field: String): Boolean = hf.containsKey(field)
  override def score: Option[Float] = Some(hit.score())
}

class EsClassGetData(val response: GetResponse) extends EsClassData {
  val map = response.getSourceAsMap
  @Nullable override def getId: String = response.getId
  @Nullable override def get(field: String): AnyRef = map.get(field)
  @Nullable override def getHighlightedField(field: String): HighlightField = null
  def isFieldHighlighted(field: String): Boolean = false
  override def score: Option[Float] = None
}

class EsClassMapData(val map: ju.Map[String, AnyRef]) extends EsClassData {
  @Nullable override def getId: String = map.get("_id").asInstanceOf[String]
  @Nullable override def get(field: String): AnyRef = map.get(field)
  @Nullable override def getHighlightedField(field: String): HighlightField = null
  override def isFieldHighlighted(field: String): Boolean = false
  override def score: Option[Float] = Option(map.get("_score").asInstanceOf[Float])
} 
开发者ID:citrum,项目名称:webby,代码行数:54,代码来源:EsClassData.scala

示例3: init

//设置package包名称以及导入依赖的类
package webby.api
import javax.annotation.Nullable


  @Nullable val prodOrConsoleProfile: HP = init()

  @Nullable protected def init(): HP = {
    if (App.isProdOrConsole) {
      val conf = App.app.configuration
      profileByName.applyOrElse[String, HP](conf.getString("production-host").get, p => sys.error("Unknown HostProfile: " + p))
    } else null.asInstanceOf[HP]
  }

  protected def profileByName: PartialFunction[String, HP]

  protected val localProfile: ThreadLocal[HP] = new ThreadLocal[HP]

  @Nullable def get: HP = if (prodOrConsoleProfile != null) prodOrConsoleProfile else localProfile.get()

  def localSet(profile: HP): Unit = {
    checkNotProd()
    localProfile.set(profile)
  }
  def localRemove(): Unit = {
    checkNotProd()
    localProfile.remove()
  }

  protected def checkNotProd() {
    require(!App.isProd, "Cannot set HostProfile in production")
  }
}

class HostProfileObjectStub extends HostProfileObject[StdHostProfile] {
  @Nullable override protected def init(): StdHostProfile = null
  override protected def profileByName: PartialFunction[String, StdHostProfile] = null
}


object HostProfileFacade {
  private var _delegate: HostProfileObject[_ <: StdHostProfile] = _

  private[api] def setDelegate(delegate: HostProfileObject[_ <: StdHostProfile]): Unit = {
    require(_delegate == null, "Delegate already set")
    _delegate = delegate
  }

  def delegate: HostProfileObject[_ <: StdHostProfile] = {
    if (_delegate == null) _delegate = new HostProfileObjectStub
    _delegate
  }

  @Nullable def get: StdHostProfile = delegate.get
  def localSet(profile: StdHostProfile): Unit = delegate.asInstanceOf[HostProfileObject[StdHostProfile]].localSet(profile)
  def localRemove(): Unit = delegate.localRemove()
} 
开发者ID:citrum,项目名称:webby,代码行数:57,代码来源:HostProfileFacade.scala

示例4: addRule0

//设置package包名称以及导入依赖的类
package webby.form.jsrule
import javax.annotation.Nullable

import webby.form.SubForm
import webby.form.field.{Field, FormListField}

import scala.collection.mutable

trait StdFormJsRules {
  def addRule0(@Nullable clientRule: JsRule, @Nullable serverRule: JsRule): Unit
  def addRule(ruleMaker: JsRuleBuilder.type => JsWhenBuilder): Unit = {
    val maker: JsWhenBuilder = ruleMaker(JsRuleBuilder)
    addRule0(maker.toJsRuleForClient, maker.toJsRuleForServer)
  }
}

object JsRuleBuilder {
  def when(cond: JsCondition): JsWhenBuilder = new JsWhenBuilder(cond)
}

class JsWhenBuilder(cond: JsCondition, actions: mutable.Buffer[JsAction] = mutable.Buffer.empty) {
  @Nullable def toJsRuleForClient: JsRule = JsRule.makeOrNull(cond, actions.filter(!_.serverOnly))
  @Nullable def toJsRuleForServer: JsRule = JsRule.makeOrNull(cond, actions.filter(!_.jsOnly))
  def add(action: JsAction): this.type = {actions += action; this}
  def addIf(condition: Boolean, action: JsAction): this.type = if (condition) add(action) else this
  def addIf2(condition: Boolean, trueAction: JsAction, falseAction: JsAction): this.type = if (condition) add(trueAction) else add(falseAction)

  def show(field: Field[_], focus: Boolean = false) = add(Visible(field, vis = true, focus = focus))
  def hide(field: Field[_], focus: Boolean = false) = add(Visible(field, vis = false, focus = focus))

  def enable(field: Field[_], focus: Boolean = false) = add(Enable(field, enable = true, focus = focus))
  def disable(field: Field[_], focus: Boolean = false) = add(Enable(field, enable = false, focus = focus))

  def require(field: Field[_], focus: Boolean = false) = add(Require(field, require = true, focus = focus))
  def optional(field: Field[_], focus: Boolean = false) = add(Require(field, require = false, focus = focus))

  def ignore(field: Field[_]) = add(Ignore(field, ignore = true))
  def unIgnore(field: Field[_]) = add(Ignore(field, ignore = false))

  def showRequire(field: Field[_], focus: Boolean = false) =
    add(Visible(field, vis = true, focus = focus))
      .add(Require(field, require = true, focus = focus))
  def hideOptional(field: Field[_], focus: Boolean = false) =
    add(Visible(field, vis = false, focus = focus))
      .add(Require(field, require = false, focus = focus))
  def hideIgnore(field: Field[_]) =
    add(Visible(field, vis = false, focus = false))
      .add(Ignore(field, ignore = true))

  def setValue[T](field: Field[T], value: T) = add(SetValue(field, value))
  def setValue2[T](field: Field[T], valueOn: T, valueOff: T) = add(SetValue2(field, valueOn, valueOff))

  def addSubform(field: FormListField[_ <: SubForm]) = add(AddSubform(field))
} 
开发者ID:citrum,项目名称:webby,代码行数:55,代码来源:StdFormJsRules.scala

示例5: parseJsValue

//设置package包名称以及导入依赖的类
package webby.form.field
import javax.annotation.Nullable

import com.fasterxml.jackson.databind.JsonNode
import webby.api.Logger
import webby.commons.text.StdStrHtml
import webby.form.{FormErrors, FormResult}

import scala.collection.mutable

trait ValueField[T] extends Field[T] {
  def parseJsValue(node: JsonNode): Either[String, T]

  
  protected def parseJsInt(node: JsonNode)(body: Int => Either[String, T]): Either[String, T] = {
    if (node.isNull || node.asText().isEmpty) Right(nullValue)
    else body(node.asInt())
  }

  def setJsValueAndValidate(@Nullable node: JsonNode): FormResult = {
    if (node != null && !node.isNull) {
      try {
        parseJsValue(node) match {
          case Right(v) => set(v); validate
          case Left(error) => FormErrors(errors = mutable.Map(shortId -> error))
        }
      } catch {
        case e: Exception =>
          Logger(getClass).warn("Error parsing js-value", e)
          FormErrors(errors = mutable.Map(shortId -> form.strings.invalidValue))
      }
    } else {
      setNull
      validate
    }
  }
} 
开发者ID:citrum,项目名称:webby,代码行数:38,代码来源:ValueField.scala

示例6: ScriptCompiler

//设置package包名称以及导入依赖的类
package webby.mvc.script.compiler
import java.io.OutputStream
import java.nio.file.{Files, Path}
import javax.annotation.Nullable

import com.google.common.base.Charsets
import webby.commons.io.IOUtils

abstract class ScriptCompiler {

  def sourceFileExt: String
  def targetFileExt: String
  def targetContentType: String
  def sourceMapFileExt: Option[String] = None

  def compile(source: String, sourcePath: Path): Either[String, String]

  def compileFile(sourcePath: Path, outputPath: Path): Either[String, Unit] = {
    val source = new String(Files.readAllBytes(sourcePath), Charsets.UTF_8)
    compile(source, sourcePath).right.map {result =>
      Files.createDirectories(outputPath.getParent)
      Files.write(outputPath, result.getBytes(Charsets.UTF_8))
      Right(())
    }
  }

  protected def runCommonProcess(command: Seq[String],
                                 @Nullable input: String = null,
                                 env: Seq[String] = Nil): Either[String, String] = {
    val proc: Process = Runtime.getRuntime.exec(command.toArray, if (env.isEmpty) null else env.toArray)

    if (input != null) {
      val os: OutputStream = proc.getOutputStream
      os.write(input.getBytes)
      os.close()
    }
    val result: String = IOUtils.readString(proc.getInputStream)
    val errors: String = IOUtils.readString(proc.getErrorStream)
    proc.waitFor()
    if (proc.exitValue() == 0 && errors.isEmpty) Right(result)
    else Left(errors)
  }

  val sourceDotExt: String = "." + sourceFileExt
  val targetDotExt: String = "." + targetFileExt
  val sourceMapDotExt: Option[String] = sourceMapFileExt.map("." + _)

  def npmScriptPath = "script/npm/node_modules/.bin"

  
  def lazyCompiler = false
} 
开发者ID:citrum,项目名称:webby,代码行数:53,代码来源:ScriptCompiler.scala

示例7: Route

//设置package包名称以及导入依赖的类
package webby.route.v2

import javax.annotation.Nullable

import io.netty.handler.codec.http.HttpMethod
import webby.commons.io.{CommonUrl, Url}
import webby.commons.text.SB

class Route(val methods: Seq[HttpMethod], val domain: String, val parts: Seq[String], val args: Seq[Any], val httpsOnly: Boolean) extends Url {
  @Nullable override def protocol: String = if (httpsOnly) "https" else null
  override def path: String = pathSb.toString

  override def pathToSb(sb: SB): SB = {
    val pi = parts.iterator
    val ai = args.iterator
    sb.sb append pi.next()
    while (ai.hasNext) {
      sb.sb append ai.next
      sb.sb append stripRegexp(pi.next())
    }
    sb
  }

  override def copyPath(newPath: String): Url = new CommonUrl(protocol, domain, newPath)

  def urlNoArgs: Url = copyPath(pathNoArgs)

  
  def pathNoArgs: String = {
    val pi = parts.iterator
    val sb = new java.lang.StringBuilder(64)
    sb append pi.next()
    while (pi.hasNext) {
      sb append stripRegexp(pi.next())
    }
    sb.toString
  }

  private def stripRegexp(part: String): String =
    if (part.length > 2 && part.charAt(0) == '<') part.substring(part.indexOf('>') + 1)
    else part
} 
开发者ID:citrum,项目名称:webby,代码行数:43,代码来源:Route.scala


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