Record Class DefaultRPCImplementationBuilder.DefaultInstanceAllocator<T>
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.network.rpc.defaults.generation.DefaultRPCImplementationBuilder.DefaultInstanceAllocator<T>
- Type Parameters:
T- the type that is being constructed by the allocator.- Record Components:
baseRPC- the base rpc to use for the constructed rpc implementation.classRPCSender- the rpc sender to use for the generated class.channelSupplier- thw channel supplier to use for rpc executions.additionalConstructorParameters- the additional super constructor parameters.internalInstanceFactory- the internal instance factory to delegate to.
- All Implemented Interfaces:
RPCImplementationBuilder.InstanceAllocator<T>
- Enclosing class:
DefaultRPCImplementationBuilder<T>
private static record DefaultRPCImplementationBuilder.DefaultInstanceAllocator<T>(@Nullable ChainableRPC baseRPC, @NonNull RPCSender classRPCSender, @NonNull Supplier<NetworkChannel> channelSupplier, @NonNull Object[] additionalConstructorParameters, @NonNull RPCInternalInstanceFactory internalInstanceFactory)
extends Record
implements RPCImplementationBuilder.InstanceAllocator<T>
The default implementation of an instance allocator using an internal instance factory as delegation.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe field for theadditionalConstructorParametersrecord component.private final @Nullable ChainableRPCThe field for thebaseRPCrecord component.private final @NonNull Supplier<NetworkChannel> The field for thechannelSupplierrecord component.The field for theclassRPCSenderrecord component.private final @NonNull RPCInternalInstanceFactoryThe field for theinternalInstanceFactoryrecord component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDefaultInstanceAllocator(@Nullable ChainableRPC baseRPC, @NonNull RPCSender classRPCSender, @NonNull Supplier<NetworkChannel> channelSupplier, @NonNull Object[] additionalConstructorParameters, @NonNull RPCInternalInstanceFactory internalInstanceFactory) Creates an instance of aDefaultInstanceAllocatorrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theadditionalConstructorParametersrecord component.allocate()Allocates an instance of the generated implementation based on the provided arguments.appendConstructorParameters(Object... parameters) Appends the given parameters to the current parameter array.baseRPC()Returns the value of thebaseRPCrecord component.changeConstructorParameter(int index, Object newConstructorParameter) Changes the parameter value at the given index to use the given parameter type instead.Returns the value of thechannelSupplierrecord component.Returns the value of theclassRPCSenderrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.insertConstructorParameters(int index, Object... parameters) Adds the parameters from the given starting index into the constructor parameter array.Returns the value of theinternalInstanceFactoryrecord component.final StringtoString()Returns a string representation of this record class.withAdditionalConstructorParameters(Object... additionalConstructorParams) Sets the additional constructor parameters which should be passed to the super constructor when allocating an instance of the generated api implementation.withBaseRPC(@Nullable ChainableRPC baseRPC) Returns a new instance allocator which uses the given base rpc when constructing the underlying implementation.withTargetChannel(@NonNull Supplier<NetworkChannel> channelSupplier) Returns a new instance allocator which uses the given channel supplier when constructing the underlying implementation.
-
Field Details
-
baseRPC
The field for thebaseRPCrecord component. -
classRPCSender
The field for theclassRPCSenderrecord component. -
channelSupplier
The field for thechannelSupplierrecord component. -
additionalConstructorParameters
The field for theadditionalConstructorParametersrecord component. -
internalInstanceFactory
The field for theinternalInstanceFactoryrecord component.
-
-
Constructor Details
-
DefaultInstanceAllocator
private DefaultInstanceAllocator(@Nullable @Nullable ChainableRPC baseRPC, @NonNull @NonNull RPCSender classRPCSender, @NonNull @NonNull Supplier<NetworkChannel> channelSupplier, @NonNull @NonNull Object[] additionalConstructorParameters, @NonNull @NonNull RPCInternalInstanceFactory internalInstanceFactory) Creates an instance of aDefaultInstanceAllocatorrecord class.- Parameters:
baseRPC- the value for thebaseRPCrecord componentclassRPCSender- the value for theclassRPCSenderrecord componentchannelSupplier- the value for thechannelSupplierrecord componentadditionalConstructorParameters- the value for theadditionalConstructorParametersrecord componentinternalInstanceFactory- the value for theinternalInstanceFactoryrecord component
-
-
Method Details
-
withBaseRPC
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> withBaseRPC(@Nullable @Nullable ChainableRPC baseRPC) Returns a new instance allocator which uses the given base rpc when constructing the underlying implementation.- Specified by:
withBaseRPCin interfaceRPCImplementationBuilder.InstanceAllocator<T>- 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
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> withTargetChannel(@NonNull @NonNull Supplier<NetworkChannel> channelSupplier) Returns a new instance allocator which uses the given channel supplier when constructing the underlying implementation.- Specified by:
withTargetChannelin interfaceRPCImplementationBuilder.InstanceAllocator<T>- 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.
-
withAdditionalConstructorParameters
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> withAdditionalConstructorParameters(Object... additionalConstructorParams) Sets the additional constructor parameters which should be passed to the super constructor when allocating an instance of the generated api implementation.- Specified by:
withAdditionalConstructorParametersin interfaceRPCImplementationBuilder.InstanceAllocator<T>- Parameters:
additionalConstructorParams- the additional constructor arguments to pass to the super constructor.- Returns:
- a new instance allocator which uses the given additional constructor parameters when allocating.
-
changeConstructorParameter
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> changeConstructorParameter(int index, Object newConstructorParameter) Changes the parameter value at the given index to use the given parameter type instead.- Specified by:
changeConstructorParameterin interfaceRPCImplementationBuilder.InstanceAllocator<T>- 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.
-
insertConstructorParameters
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> insertConstructorParameters(int index, Object... parameters) Adds the parameters from the given starting index into the constructor parameter array.- Specified by:
insertConstructorParametersin interfaceRPCImplementationBuilder.InstanceAllocator<T>- 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.
-
appendConstructorParameters
@NonNull public @NonNull RPCImplementationBuilder.InstanceAllocator<T> appendConstructorParameters(Object... parameters) Appends the given parameters to the current parameter array.- Specified by:
appendConstructorParametersin interfaceRPCImplementationBuilder.InstanceAllocator<T>- Parameters:
parameters- the parameter values to append.- Returns:
- a new instance allocator with the given parameters appended.
-
allocate
Allocates an instance of the generated implementation based on the provided arguments.- Specified by:
allocatein interfaceRPCImplementationBuilder.InstanceAllocator<T>- Returns:
- an allocated instance of the implemented target class.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
baseRPC
-
classRPCSender
Returns the value of theclassRPCSenderrecord component.- Returns:
- the value of the
classRPCSenderrecord component
-
channelSupplier
Returns the value of thechannelSupplierrecord component.- Returns:
- the value of the
channelSupplierrecord component
-
additionalConstructorParameters
Returns the value of theadditionalConstructorParametersrecord component.- Returns:
- the value of the
additionalConstructorParametersrecord component
-
internalInstanceFactory
Returns the value of theinternalInstanceFactoryrecord component.- Returns:
- the value of the
internalInstanceFactoryrecord component
-