Interface RPCImplementationBuilder.InstanceAllocator<T>

Type Parameters:
T - the type that is being constructed.
Enclosing interface:
RPCImplementationBuilder<T>

public static interface RPCImplementationBuilder.InstanceAllocator<T>
An allocator for instances of generated rpc implementations.
Since:
4.0
  • Method Details

    • withBaseRPC

      Returns a new instance allocator which uses the given base rpc when constructing the underlying implementation.
      Parameters:
      baseRPC - the base rpc to use for the rpc executions in the target class, can be null.
      Returns:
      a new instance allocator instance which uses the given base rpc when allocating.
    • withTargetChannel

      Returns a new instance allocator which uses the given channel supplier when constructing the underlying implementation.
      Parameters:
      channelSupplier - the channel supplier to use as a target for all rpc calls.
      Returns:
      a new instance allocator which uses the given channel supplier when allocating.
      Throws:
      NullPointerException - if the given channel supplier is null.
    • withAdditionalConstructorParameters

      @NonNull @Contract("_ -> new") @NonNull RPCImplementationBuilder.InstanceAllocator<T> withAdditionalConstructorParameters(Object... additionalConstructorParameters)
      Sets the additional constructor parameters which should be passed to the super constructor when allocating an instance of the generated api implementation.
      Parameters:
      additionalConstructorParameters - the additional constructor arguments to pass to the super constructor.
      Returns:
      a new instance allocator which uses the given additional constructor parameters when allocating.
      Throws:
      NullPointerException - if the given additional constructor parameters are null.
    • changeConstructorParameter

      @NonNull @Contract("_, _ -> new") @NonNull RPCImplementationBuilder.InstanceAllocator<T> changeConstructorParameter(int index, Object newConstructorParameter)
      Changes the parameter value at the given index to use the given parameter type instead.
      Parameters:
      index - the index of the parameter to change.
      newConstructorParameter - the new parameter value to use.
      Returns:
      a new instance allocator with the parameter value changed at the given index.
      Throws:
      IndexOutOfBoundsException - if the given index is out of bounds of the current parameter array.
    • insertConstructorParameters

      @NonNull @Contract("_, _ -> new") @NonNull RPCImplementationBuilder.InstanceAllocator<T> insertConstructorParameters(int index, Object... parameters)
      Adds the parameters from the given starting index into the constructor parameter array.
      Parameters:
      index - the index where to start the parameter insertion.
      parameters - the parameters to insert.
      Returns:
      a new instance allocator with the given parameters added.
      Throws:
      NullPointerException - if the given parameter array is null.
      IndexOutOfBoundsException - if the given start index is out of bounds of the current parameter array.
    • appendConstructorParameters

      @NonNull @Contract("_ -> new") @NonNull RPCImplementationBuilder.InstanceAllocator<T> appendConstructorParameters(Object... parameters)
      Appends the given parameters to the current parameter array.
      Parameters:
      parameters - the parameter values to append.
      Returns:
      a new instance allocator with the given parameters appended.
      Throws:
      NullPointerException - if the given parameter array is null.
    • allocate

      @NonNull @Contract("-> new") T allocate()
      Allocates an instance of the generated implementation based on the provided arguments.
      Returns:
      an allocated instance of the implemented target class.
      Throws:
      IllegalStateException - if the allocation is not possible.