Skip to content

hank-whu/common4s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

common4s

common utils for scala

Example

package example

import commons.mapper.Mappers

object EasyExample {
	def main(args : Array[String]) : Unit = {
		var map : collection.Map[String, Any] = 
			Map("id" -> 9527L, "name" -> "Hank", "age" -> 21, "sex" -> 1.toShort)

		var bean : AnyRef = Mappers.mapToBean[ScalaStudent](map)
		println(bean)

		bean = Mappers.mapToBean[JavaStudent](map)
		println(bean)

		map = Map("id" -> "9527", "name" -> "Hank", "age" -> "21", "sex" -> "1")

		bean = Mappers.mapToBean[ScalaStudent](map, true)
		println(bean)

		map = Mappers.beanToMap(bean)
		println(map)

		println

		map = Map("id" -> 9527L, "name" -> "Hank", "age" -> 21, "sex" -> 1.toShort)
		ExecTimeUtils.repeatExec(100000, Mappers.mapToBean[ScalaStudent](map))
		ExecTimeUtils.time("mapToBean", 1000000, Mappers.mapToBean[ScalaStudent](map))

		println

		ExecTimeUtils.repeatExec(100000, Mappers.beanToMap(bean))
		ExecTimeUtils.time("beanToMap", 1000000, Mappers.beanToMap(bean))
	}
}

About

common utils for scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published