I am trying to build a custom connector using Mule's Java SDK. Basically what I am trying to do is to add functionality to the current cache scope to let the developers to be able to add a condition upon which the scope should store something in the cache based on the final result (and some other features too, but this is what I am mainly stuck at). For example only store a database query response if the result is not empty. To do this I am thinking to pass a function as an argument in the operation which will return a Boolean and on the basis of the result the operation will store the result in the cache. The final function definition of the operation would look something like this
public void cache(String key, Function(or something else?) storeInCache, Chain connectors, CompletionCallback<Object, Object> callback) {}
Is it possible to do what I am trying to do. I am open to any suggestions. May be there is any alternative way to do this?
Thanks