Record Class DefaultRPCMethodMetadata
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.impl.network.rpc.introspec.DefaultRPCMethodMetadata
- Record Components:
concrete- if the method is concretely implemented, false if the method is abstract.asyncReturnType- if the method has an async return type (returns a supported future subtype).compilerGenerated- if the method was inserted into the class by the compiler.executionResultIgnored- if the method was specifically annotated to not wait for the rpc execution.name- the name of the method.returnType- the full generic return type of the method.unwrappedReturnType- the return type of the method after unwrapping, e.g. if the returning an async type.parameterTypes- the fully generic parameter types.methodType- the method type of the method.definingClass- the class in which the method is defined.executionTimeout- the execution timeout of the method, null if not defined.chainMetadata- the metadata for chain implementation, if annotated withRPCChained.
- All Implemented Interfaces:
eu.cloudnetservice.driver.base.Named, eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
public record DefaultRPCMethodMetadata(boolean concrete, boolean asyncReturnType, boolean compilerGenerated, boolean executionResultIgnored, @NonNull String name, @NonNull Type returnType, @NonNull Type unwrappedReturnType, @NonNull Type[] parameterTypes, @NonNull MethodType methodType, @NonNull Class<?> definingClass, @Nullable Duration executionTimeout, @Nullable DefaultRPCMethodMetadata.MethodChainMetadata chainMetadata)
extends Record
implements eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
Metadata information about a method that can be used with RPC.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMetadata information for a chained invocation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanThe field for theasyncReturnTyperecord component.private final @Nullable DefaultRPCMethodMetadata.MethodChainMetadataThe field for thechainMetadatarecord component.private final booleanThe field for thecompilerGeneratedrecord component.private final booleanThe field for theconcreterecord component.The field for thedefiningClassrecord component.private final booleanThe field for theexecutionResultIgnoredrecord component.The field for theexecutionTimeoutrecord component.private final @NonNull MethodTypeThe field for themethodTyperecord component.The field for thenamerecord component.The field for theparameterTypesrecord component.The field for thereturnTyperecord component.The field for theunwrappedReturnTyperecord component. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRPCMethodMetadata(boolean concrete, boolean asyncReturnType, boolean compilerGenerated, boolean executionResultIgnored, @NonNull String name, @NonNull Type returnType, @NonNull Type unwrappedReturnType, @NonNull Type[] parameterTypes, @NonNull MethodType methodType, @NonNull Class<?> definingClass, @Nullable Duration executionTimeout, @Nullable DefaultRPCMethodMetadata.MethodChainMetadata chainMetadata) Creates an instance of aDefaultRPCMethodMetadatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theasyncReturnTyperecord component.Returns the value of thechainMetadatarecord component.booleanReturns the value of thecompilerGeneratedrecord component.booleanconcrete()Returns the value of theconcreterecord component.Returns the value of thedefiningClassrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanReturns the value of theexecutionResultIgnoredrecord component.Returns the value of theexecutionTimeoutrecord component.private static @Nullable DefaultRPCMethodMetadata.MethodChainMetadataextractAndValidateChainMeta(@NonNull Method method, @NonNull Class<?> rawReturnType, @Nullable eu.cloudnetservice.driver.network.rpc.annotation.RPCChained chainAnnotation) Extract and validate the metadata of the chain annotation information.(package private) static @NonNull DefaultRPCMethodMetadatafromMethod(@NonNull Method method) Constructs and validates a rpc method metadata based on the properties of the given method.final inthashCode()Returns a hash code value for this object.Returns the value of themethodTyperecord component.name()Returns the value of thenamerecord component.Returns the value of theparameterTypesrecord component.Returns the value of thereturnTyperecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theunwrappedReturnTyperecord component.unwrapWrappedFutureType(@NonNull Method method, @NonNull Type type) Unwraps the first (and only) type parameter of the given type, if the raw type is a future, to get the actual return type to use for network codec.private static voidvalidateBounds(@NonNull Method method, @NonNull Type type) Ensures that the given type is fully bound, throwing an exception if that is not the case.private static voidvalidateChainBaseClass(@NonNull Method method, @NonNull Class<?> chainBaseImpl) Validates that the given chain base class is valid and can be implemented by code generation.
-
Field Details
-
concrete
private final boolean concreteThe field for theconcreterecord component. -
asyncReturnType
private final boolean asyncReturnTypeThe field for theasyncReturnTyperecord component. -
compilerGenerated
private final boolean compilerGeneratedThe field for thecompilerGeneratedrecord component. -
executionResultIgnored
private final boolean executionResultIgnoredThe field for theexecutionResultIgnoredrecord component. -
name
-
returnType
The field for thereturnTyperecord component. -
unwrappedReturnType
The field for theunwrappedReturnTyperecord component. -
parameterTypes
The field for theparameterTypesrecord component. -
methodType
The field for themethodTyperecord component. -
definingClass
The field for thedefiningClassrecord component. -
executionTimeout
The field for theexecutionTimeoutrecord component. -
chainMetadata
The field for thechainMetadatarecord component.
-
-
Constructor Details
-
DefaultRPCMethodMetadata
public DefaultRPCMethodMetadata(boolean concrete, boolean asyncReturnType, boolean compilerGenerated, boolean executionResultIgnored, @NonNull @NonNull String name, @NonNull @NonNull Type returnType, @NonNull @NonNull Type unwrappedReturnType, @NonNull @NonNull Type[] parameterTypes, @NonNull @NonNull MethodType methodType, @NonNull @NonNull Class<?> definingClass, @Nullable @Nullable Duration executionTimeout, @Nullable @Nullable DefaultRPCMethodMetadata.MethodChainMetadata chainMetadata) Creates an instance of aDefaultRPCMethodMetadatarecord class.- Parameters:
concrete- the value for theconcreterecord componentasyncReturnType- the value for theasyncReturnTyperecord componentcompilerGenerated- the value for thecompilerGeneratedrecord componentexecutionResultIgnored- the value for theexecutionResultIgnoredrecord componentname- the value for thenamerecord componentreturnType- the value for thereturnTyperecord componentunwrappedReturnType- the value for theunwrappedReturnTyperecord componentparameterTypes- the value for theparameterTypesrecord componentmethodType- the value for themethodTyperecord componentdefiningClass- the value for thedefiningClassrecord componentexecutionTimeout- the value for theexecutionTimeoutrecord componentchainMetadata- the value for thechainMetadatarecord component
-
-
Method Details
-
fromMethod
Constructs and validates a rpc method metadata based on the properties of the given method.- Parameters:
method- the method to construct the rpc method metadata for.- Returns:
- the constructed rpc method metadata.
- Throws:
NullPointerException- if the given method is null.IllegalStateException- if some precondition, to ensure functionality with rpc, fails.
-
validateBounds
Ensures that the given type is fully bound, throwing an exception if that is not the case. The given method will be used as a hint to direct into the direction of the method that caused the issue.- Parameters:
method- the method that is related to the type being checked.type- the type to check if fully bound.- Throws:
NullPointerException- if the given method or type is null.IllegalStateException- if the given type is not fully bound.
-
extractAndValidateChainMeta
@Nullable private static @Nullable DefaultRPCMethodMetadata.MethodChainMetadata extractAndValidateChainMeta(@NonNull @NonNull Method method, @NonNull @NonNull Class<?> rawReturnType, @Nullable @Nullable eu.cloudnetservice.driver.network.rpc.annotation.RPCChained chainAnnotation) Extract and validate the metadata of the chain annotation information. Returns null if the given chain annotation is null.- Parameters:
method- the method on which the chain annotation is located.rawReturnType- the raw return type of the method.chainAnnotation- the chain annotation instance located on the method.- Returns:
- the extracted method chain metadata.
- Throws:
NullPointerException- if the given method or raw return type is null.IllegalStateException- if chain annotation has invalid data provided.
-
validateChainBaseClass
private static void validateChainBaseClass(@NonNull @NonNull Method method, @NonNull @NonNull Class<?> chainBaseImpl) Validates that the given chain base class is valid and can be implemented by code generation.- Parameters:
method- the method on which the chain annotation is located.chainBaseImpl- the chain base type which should be implemented.- Throws:
NullPointerException- if the given method or class is null.IllegalStateException- if a validation error occurs.
-
unwrapWrappedFutureType
@Nullable private static @Nullable Type unwrapWrappedFutureType(@NonNull @NonNull Method method, @NonNull @NonNull Type type) Unwraps the first (and only) type parameter of the given type, if the raw type is a future, to get the actual return type to use for network codec.- Parameters:
method- the method that is related to the type being unwrapped.type- the type to unwrap the future return type of.- Returns:
- the return type of the given future, null if the given type is not a future.
- Throws:
NullPointerException- if the given type or method is null.IllegalStateException- if the given type has no or multiple type parameters while being a future.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
concrete
-
asyncReturnType
public boolean asyncReturnType()Returns the value of theasyncReturnTyperecord component.- Specified by:
asyncReturnTypein interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
asyncReturnTyperecord component
-
compilerGenerated
public boolean compilerGenerated()Returns the value of thecompilerGeneratedrecord component.- Returns:
- the value of the
compilerGeneratedrecord component
-
executionResultIgnored
public boolean executionResultIgnored()Returns the value of theexecutionResultIgnoredrecord component.- Specified by:
executionResultIgnoredin interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
executionResultIgnoredrecord component
-
name
-
returnType
Returns the value of thereturnTyperecord component.- Specified by:
returnTypein interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
returnTyperecord component
-
unwrappedReturnType
Returns the value of theunwrappedReturnTyperecord component.- Returns:
- the value of the
unwrappedReturnTyperecord component
-
parameterTypes
Returns the value of theparameterTypesrecord component.- Specified by:
parameterTypesin interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
parameterTypesrecord component
-
methodType
Returns the value of themethodTyperecord component.- Specified by:
methodTypein interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
methodTyperecord component
-
definingClass
Returns the value of thedefiningClassrecord component.- Specified by:
definingClassin interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
definingClassrecord component
-
executionTimeout
Returns the value of theexecutionTimeoutrecord component.- Specified by:
executionTimeoutin interfaceeu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata- Returns:
- the value of the
executionTimeoutrecord component
-
chainMetadata
Returns the value of thechainMetadatarecord component.- Returns:
- the value of the
chainMetadatarecord component
-