GroovyChainAction equivalent in Java?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GroovyChainAction equivalent in Java?

Rafal
Hi guys,

I'm trying to build a Rest endpoint in Java similar to `BookRestEndpoint` from the examples (https://github.com/ratpack/example-books/blob/master/src/main/groovy/ratpack/example/books/BookRestEndpoint.groovy).

Is there a `GroovyChainAction` equivalent available in Java, or do I need to implement `Action<Chain>`? (7 methods :/)
Reply | Threaded
Open this post in threaded view
|

Re: GroovyChainAction equivalent in Java?

davidmc24
I believe that Action<Chain> is indeed what you want.  However, note that Action is a @FunctionalInterface.  It only has a single method that you need to implement, "void execute(T)", and it can be implemented as a lambda expression.  All the other methods are either static or have default implementations.
Reply | Threaded
Open this post in threaded view
|

Re: GroovyChainAction equivalent in Java?

Rafal
Perfect.
I didn't notice that `void execute(Chain chain)` is the only method that needs to be implemented, my mistake.

Thanks for your help!
Reply | Threaded
Open this post in threaded view
|

Re: GroovyChainAction equivalent in Java?

davidmc24
You're very welcome.