-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Guillaume Martres <[email protected]>
- Loading branch information
Showing
6 changed files
with
70 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
inspecting field brandName | ||
@MyColumnBase(name="BRAND_NAME") | ||
inspecting field companyName | ||
@MyColumnBase(name="COMPANY_NAME") | ||
inspecting method companyName | ||
inspecting method brandName | ||
inspecting constructor MyTable | ||
inspecting param brandName | ||
inspecting param companyName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MyColumnBase { | ||
String name() default ""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import scala.annotation.meta.field | ||
|
||
type MyColumn = MyColumnBase @field | ||
|
||
class MyTable( | ||
@(MyColumnBase @field)(name="BRAND_NAME") | ||
val brandName: String, | ||
@MyColumn(name="COMPANY_NAME") | ||
val companyName: String, | ||
) | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val clasz = classOf[MyTable] | ||
|
||
for (m <- clasz.getDeclaredFields) { | ||
m.setAccessible(true) | ||
println(s"inspecting field ${m.getName}") | ||
for a <- m.getAnnotations() do | ||
println(a) | ||
} | ||
|
||
for (m <- clasz.getDeclaredMethods) { | ||
m.setAccessible(true) | ||
println(s"inspecting method ${m.getName}") | ||
for a <- m.getAnnotations() do | ||
println(a) | ||
} | ||
|
||
for c <- clasz.getDeclaredConstructors do | ||
c.setAccessible(true) | ||
println(s"inspecting constructor ${c.getName}") | ||
for p <- c.getParameters do | ||
println(s"inspecting param ${p.getName}") | ||
for a <- p.getAnnotations do | ||
println(s"annotation $a") |