-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #518 from jbl428/feat/jpql-property-description
Add support for java getter
- Loading branch information
Showing
24 changed files
with
297 additions
and
29 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
12 changes: 12 additions & 0 deletions
12
...rc/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/introspector/JpqlEntityIntrospector.kt
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,12 @@ | ||
package com.linecorp.kotlinjdsl.render.jpql.introspector | ||
|
||
import com.linecorp.kotlinjdsl.SinceJdsl | ||
import kotlin.reflect.KCallable | ||
|
||
/** | ||
* Abstract class to get the entity information by introspecting KClass. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
abstract class JpqlEntityIntrospector : JpqlIntrospector { | ||
override fun introspect(property: KCallable<*>): JpqlPropertyDescription? = null | ||
} |
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
12 changes: 12 additions & 0 deletions
12
...c/main/kotlin/com/linecorp/kotlinjdsl/render/jpql/introspector/JpqlPropertyDescription.kt
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,12 @@ | ||
package com.linecorp.kotlinjdsl.render.jpql.introspector | ||
|
||
import com.linecorp.kotlinjdsl.SinceJdsl | ||
|
||
/** | ||
* Interface to represent the property information. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
interface JpqlPropertyDescription { | ||
@SinceJdsl("3.1.0") | ||
val name: String | ||
} |
12 changes: 12 additions & 0 deletions
12
.../main/kotlin/com/linecorp/kotlinjdsl/render/jpql/introspector/JpqlPropertyIntrospector.kt
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,12 @@ | ||
package com.linecorp.kotlinjdsl.render.jpql.introspector | ||
|
||
import com.linecorp.kotlinjdsl.SinceJdsl | ||
import kotlin.reflect.KClass | ||
|
||
/** | ||
* Abstract class to get the entity information by introspecting KCallable. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
abstract class JpqlPropertyIntrospector : JpqlIntrospector { | ||
override fun introspect(type: KClass<*>): JpqlEntityDescription? = null | ||
} |
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
33 changes: 33 additions & 0 deletions
33
.../linecorp/kotlinjdsl/render/jpql/introspector/impl/KotlinStyleJpqlPropertyIntrospector.kt
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,33 @@ | ||
package com.linecorp.kotlinjdsl.render.jpql.introspector.impl | ||
|
||
import com.linecorp.kotlinjdsl.Internal | ||
import com.linecorp.kotlinjdsl.render.jpql.introspector.JpqlPropertyDescription | ||
import com.linecorp.kotlinjdsl.render.jpql.introspector.JpqlPropertyIntrospector | ||
import kotlin.reflect.KCallable | ||
import kotlin.reflect.KFunction1 | ||
import kotlin.reflect.KProperty1 | ||
|
||
/** | ||
* Introspector that introspects a property name in KCallable using Kotlin style. | ||
*/ | ||
@Internal | ||
class KotlinStyleJpqlPropertyIntrospector : JpqlPropertyIntrospector() { | ||
override fun introspect(property: KCallable<*>): JpqlPropertyDescription? { | ||
return when (property) { | ||
is KProperty1<*, *> -> KotlinStyleProperty(property.name) | ||
is KFunction1<*, *> -> KotlinStyleProperty(resolvePropertyName(property)) | ||
else -> null | ||
} | ||
} | ||
|
||
private fun resolvePropertyName(getter: KFunction1<*, *>): String = | ||
if (getter.name.startsWith("is")) { | ||
getter.name | ||
} else { | ||
getter.name.removePrefix("get").replaceFirstChar { it.lowercase() } | ||
} | ||
} | ||
|
||
private data class KotlinStyleProperty( | ||
override val name: String, | ||
) : JpqlPropertyDescription |
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
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
Oops, something went wrong.