Interface ChainableRPC

All Superinterfaces:
RPCExecutable, RPCProvider
All Known Subinterfaces:
RPC, RPCChain

public interface ChainableRPC extends RPCExecutable, RPCProvider
A chainable rpc is a powerful extension to the normal rpc system which allows a developer to execute code on the result of the previous method call. For example, the first rpc call might return an integer from the method availableDiskSpace, you can then join on the integer of the method result and call toString directly on the result of that method.

A rpc chain is completely null aware, you can call a method in the chain which returns null and the handler will ensure that the result send back to the network component matches the expected method result, either returning null for a null-accepting return type or the default value of a primitive type (for example an integer will be normalized to 0).

Exceptions that happen on the way through the chain will get serialized and sent back to the calling network component resulting in an exception on the caller site as well.

RPC chains are completely safe to re-use, every join on a rpc chain will result in a new rpc chain instance.

Since:
4.0
  • Method Details

    • join

      Adds a join statement to the current rpc chain. This method always returns a new rpc chain with the given rpc as the last rpc. Therefore, the result type expectation when firring the rpc chain is based on the last rpc given to the chain using this method.

      A chain can be re-used infinite times and even joined on without making a change to the original rpc chain.

      Parameters:
      rpc - the rpc to join on the result of the current chain.
      Returns:
      a new rpc chain instance with the given rpc as its head rpc.
      Throws:
      NullPointerException - if the given rpc is null.