本文整理汇总了Scala中scala.beans.BeanInfo类的典型用法代码示例。如果您正苦于以下问题:Scala BeanInfo类的具体用法?Scala BeanInfo怎么用?Scala BeanInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BeanInfo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Product
//设置package包名称以及导入依赖的类
package model
import scala.beans.BeanInfo
case class Product(
shipping:Float,
articleNumber:String,
title:String,
descriptionShort:String,
displayPrice:String,
imageUrl:String,
deepLink:String,
productCategoryID:String,
productCategoryName:String)
@BeanInfo
case class Employee(name:String, id:Int)
object Employee {
def asJson(e: Employee): String ={
s"""{"name":"${e.name}", "id":"${e.id}"}"""
}
}
示例2: Phrase
//设置package包名称以及导入依赖的类
package org.mireynol.model
import scala.beans.BeanInfo
import scala.collection.mutable.ListBuffer
@BeanInfo
case class Phrase( text : String ) {
final val ngrams : List[ NGram ] = makeNGrams( LangConfig.SENTENCE_BEGIN + " " + text + " " + LangConfig.SENTENCE_END )
def makeNGrams( text : String ) : List[ NGram ] = {
val strings : Array[ String ] = text.split( " " )
val ngrams : ListBuffer[ NGram ] = ListBuffer[ NGram ]( )
if ( strings.size >= LangConfig.NGRAM_SIZE ) {
for ( i <- 0 to strings.size - LangConfig.NGRAM_SIZE ) {
ngrams += NGram( strings.slice( i, strings.size ) )
}
}
ngrams.toList
}
}
示例3: NGram
//设置package包名称以及导入依赖的类
package org.mireynol.model
import scala.beans.BeanInfo
@BeanInfo
case class NGram( strings : Array[ String ] ) {
val root : String = deriveRoot( strings )
val stem : String = deriveStem( strings )
private def deriveRoot( strings : Array[ String ] ) : String = {
val fullGram = strings.slice( 0, LangConfig.NGRAM_SIZE )
val root = fullGram.slice( 0, fullGram.size - 1 )
root.mkString( " " )
}
private def deriveStem( strings : Array[ String ] ) : String = {
val fullGram = strings.slice( 0, LangConfig.NGRAM_SIZE )
fullGram( LangConfig.NGRAM_SIZE - 1 )
}
override def toString( ) : String = "NGram{ ( " + root + " ) | " + stem + " }"
override def equals( obj : scala.Any ) : Boolean = {
if ( !obj.isInstanceOf[ NGram ] ) false
val other = obj.asInstanceOf[ NGram ]
if ( other.root == this.root && other.stem == this.stem ) {
true
}
else {
false
}
}
}