-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add path method for KFunction1
#521
Changes from all commits
341ddfc
e5e3a00
a8cd463
d0d35c4
04cef12
581d5d3
84fc35c
6362262
74ab44d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ import java.math.BigDecimal | |
import java.math.BigInteger | ||
import kotlin.internal.Exact | ||
import kotlin.reflect.KClass | ||
import kotlin.reflect.KFunction1 | ||
import kotlin.reflect.KProperty1 | ||
|
||
/** | ||
|
@@ -194,6 +195,15 @@ open class Jpql : JpqlDsl { | |
return Paths.path(property) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the property. | ||
* The path starts from the entity which is the owner of the property. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
fun <T : Any, V> path(getter: KFunction1<T, @Exact V>): Path<V & Any> { | ||
return Paths.path(getter) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the entity and property. | ||
*/ | ||
|
@@ -202,6 +212,14 @@ open class Jpql : JpqlDsl { | |
return Paths.path(this.toEntity(), property) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the entity and property. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
fun <T : Any, V> Entityable<T>.path(getter: KFunction1<T, @Exact V>): Path<V & Any> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to put There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It works in the test, but it's probably because the receiver's T is cast to a supertype. This causes the type to be broken when chaining occurs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when i first put
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha, I see. Thank you for the confirmation. |
||
return Paths.path(this.toEntity(), getter) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the path and property. | ||
*/ | ||
|
@@ -210,6 +228,14 @@ open class Jpql : JpqlDsl { | |
return Paths.path(this.toPath(), property) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the path and property. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
fun <T : Any, V> Pathable<T>.path(getter: KFunction1<T, @Exact V>): Path<V & Any> { | ||
return Paths.path(this.toPath(), getter) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the entity and property. | ||
*/ | ||
|
@@ -218,6 +244,14 @@ open class Jpql : JpqlDsl { | |
return Paths.path(this.toEntity(), property) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the entity and property. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
operator fun <T : Any, V> Entityable<T>.invoke(getter: KFunction1<T, @Exact V>): Path<V & Any> { | ||
return Paths.path(this.toEntity(), getter) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the path and property. | ||
*/ | ||
|
@@ -226,6 +260,14 @@ open class Jpql : JpqlDsl { | |
return Paths.path(this.toPath(), property) | ||
} | ||
|
||
/** | ||
* Creates a path expression with the path and property. | ||
*/ | ||
@SinceJdsl("3.1.0") | ||
operator fun <T : Any, V> Pathable<T>.invoke(getter: KFunction1<T, @Exact V>): Path<V & Any> { | ||
return Paths.path(this.toPath(), getter) | ||
} | ||
|
||
/** | ||
* Creates an aliased expression with the alias expression. | ||
* The aliased expression can be referenced by the alias expression. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한국어까지 같이 작성해주셔서 정말 감사합니다. ❤️