Make the assertion lambdas Kotlin friendly
See original GitHub issueFeature summary
Some assertions accept a functor:
public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(ThrowingCallable shouldRaiseThrowable,
Class<THROWABLE> type) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseThrowable, type);
}
Kotlin has a syntax for lambdas, so it could call:
catchThrowableOfType(NotFoundException::class.java) {
connectionService.findBy(hubId = "hub2", connId = "conn1")
}
But as it is, it needs to stick with the less readable:
catchThrowableOfType( {
connectionService.findBy(hubId = "hub2", connId = "conn1")
}, NotFoundException::class.java)
Could you please add some overrides, moving the functors to the last place? Like,
public static <THROWABLE extends Throwable> THROWABLE catchThrowableOfType(
Class<THROWABLE> type, ThrowingCallable shouldRaiseThrowable) {
return AssertionsForClassTypes.catchThrowableOfType(shouldRaiseThrowable, type);
}
Thanks for considering.
AssertJ 3.23.11
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
High-order functions and lambdas - Kotlin
Kotlin functions are first-class, which means they can be stored in variables and data structures, and can be passed as arguments to and ......
Read more >Evolution from Java Method to Inline Lambda - YouTube
An overview discussion of lambdas in Kotlin. We start by looking at a Java method, and we convert it to a Kotlin function....
Read more >Lambdas assigned to variables in Kotlin. Why? - Stack Overflow
When is it needed, recommended, advantageous to define a variable as a lambda rather than define a function to it?
Read more >Using Kotlin in a Serverless Architecture with AWS Lambda ...
So far I have covered all the basics to set up, build and deploy your Serverless + Kotlin project using AWS Lambda as...
Read more >Lambda Expressions in Kotlin - Baeldung
A quick and practical guide to Lambda Expressions in Kotlin. ... If we wanted to create a lambda that multiplies its single argument...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Team decision: let’s add
catchThrowableOfType(Class<THROWABLE>, ThrowingCallable)
and deprecate the existingcatchThrowableOfType(ThrowingCallable, Class<THROWABLE>)
.We believe that the readability of Java code can also benefit from this change.
@java-coding-prodigy would you like to take care of these changes?
Yes, that would make sense.