Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuwei-k/shapeless-java-records
derive `shapeless.Generic` instances for Java Records and Sealed Classes
https://github.com/xuwei-k/shapeless-java-records
generic-programming java macros scala shapeless
Last synced: 18 days ago
JSON representation
derive `shapeless.Generic` instances for Java Records and Sealed Classes
- Host: GitHub
- URL: https://github.com/xuwei-k/shapeless-java-records
- Owner: xuwei-k
- License: mit
- Created: 2020-09-29T07:41:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-16T21:31:14.000Z (21 days ago)
- Last Synced: 2024-10-18T21:22:23.016Z (19 days ago)
- Topics: generic-programming, java, macros, scala, shapeless
- Language: Scala
- Homepage:
- Size: 108 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# shapeless java records
[![scaladoc](https://javadoc.io/badge2/com.github.xuwei-k/shapeless-java-records_2.13/javadoc.svg)](https://javadoc.io/doc/com.github.xuwei-k/shapeless-java-records_2.13)
## setup
- install jdk 15 or later
- `build.sbt````scala
// if jdk 15 or 16
javacOptions ++= Seq("--enable-preview", "--release", scala.util.Properties.javaSpecVersion)scalaVersion := // 2.12.x or 2.13.x
libraryDependencies += "com.github.xuwei-k" %% "shapeless-java-records" % "latest version"
// https://github.com/scala/bug/issues/11908
// https://github.com/scala/bug/issues/12159
compileOrder := CompileOrder.JavaThenScala
```- run `sbt -J--enable-preview`
## usage
```scala
import shapeless._
import shapeless.JavaRecordGeneric._// summon shapeless.Generic instances
Generic[YourJavaRecordType]
Generic[YourJavaSealedType]
```### LabelledGeneric
```scala
import shapeless._
import shapeless.JavaRecordGeneric._
import shapeless.JavaRecordGeneric.string._ // string label
// or import shapeless.JavaRecordGeneric.symbol._LabelledGeneric[YourJavaRecordType]
LabelledGeneric[YourJavaSealedType]
```