Record Class RPCGenerationContext.AdditionalInstanceFactoryField
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCGenerationContext.AdditionalInstanceFactoryField
- Record Components:
name- the name of the field.targetType- the target type that is being constructed by the factory.instanceFactory- the instance factory.
- Enclosing class:
RPCGenerationContext
private static record RPCGenerationContext.AdditionalInstanceFactoryField(@NonNull String name, @NonNull Class<?> targetType, @NonNull RPCInternalInstanceFactory instanceFactory)
extends Record
A field that holds an additional instance factory that is accessed to allocate instances of chain classes.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull RPCInternalInstanceFactoryThe field for theinstanceFactoryrecord component.The field for thenamerecord component.The field for thetargetTyperecord component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAdditionalInstanceFactoryField(@NonNull String name, @NonNull Class<?> targetType, @NonNull RPCInternalInstanceFactory instanceFactory) Creates an instance of aAdditionalInstanceFactoryFieldrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyToClassAndConstructor(int fieldIndex, @NonNull ClassDesc generatingClass, @NonNull ClassBuilder classBuilder, @NonNull CodeBuilder constructorCode) Adds this field into the target class builder and adds code to the constructor to initialize the field value.booleanforFactory(@NonNull Class<?> targetType, @NonNull RPCInternalInstanceFactory instanceFactory) Constructs a field that holds an additional instance factory for the given target type.inthashCode()Returns the value of theinstanceFactoryrecord component.name()Returns the value of thenamerecord component.Returns the value of thetargetTyperecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
name
-
targetType
The field for thetargetTyperecord component. -
instanceFactory
The field for theinstanceFactoryrecord component.
-
-
Constructor Details
-
AdditionalInstanceFactoryField
private AdditionalInstanceFactoryField(@NonNull @NonNull String name, @NonNull @NonNull Class<?> targetType, @NonNull @NonNull RPCInternalInstanceFactory instanceFactory) Creates an instance of aAdditionalInstanceFactoryFieldrecord class.- Parameters:
name- the value for thenamerecord componenttargetType- the value for thetargetTyperecord componentinstanceFactory- the value for theinstanceFactoryrecord component
-
-
Method Details
-
forFactory
@NonNull public static @NonNull RPCGenerationContext.AdditionalInstanceFactoryField forFactory(@NonNull @NonNull Class<?> targetType, @NonNull @NonNull RPCInternalInstanceFactory instanceFactory) Constructs a field that holds an additional instance factory for the given target type.- Parameters:
targetType- the target type which is constructed by the instance factory.instanceFactory- the instance factory that should be used for initialisation.- Returns:
- the generated factory field information.
- Throws:
NullPointerException- if the given target type or instance factory is null.
-
applyToClassAndConstructor
public void applyToClassAndConstructor(int fieldIndex, @NonNull @NonNull ClassDesc generatingClass, @NonNull @NonNull ClassBuilder classBuilder, @NonNull @NonNull CodeBuilder constructorCode) Adds this field into the target class builder and adds code to the constructor to initialize the field value. This method uses a deterministic way to generate the field name, so each invocation leads to the same field name result.- Parameters:
fieldIndex- the index of the current field that is being added to the class (1-based).generatingClass- the descriptor of the class that is being generated.classBuilder- the builder of the class being generated.constructorCode- the builder of the constructor code for the current class.- Throws:
NullPointerException- if the current class desc, class builder or constructor builder is null.
-
equals
-
hashCode
-
toString
-
name
-
targetType
Returns the value of thetargetTyperecord component.- Returns:
- the value of the
targetTyperecord component
-
instanceFactory
Returns the value of theinstanceFactoryrecord component.- Returns:
- the value of the
instanceFactoryrecord component
-