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 with RPCChained.
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
  • Field Details

  • Constructor Details

  • 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

      private static void validateBounds(@NonNull @NonNull Method method, @NonNull @NonNull Type type)
      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

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • concrete

      public boolean concrete()
      Returns the value of the concrete record component.
      Specified by:
      concrete in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the concrete record component
    • asyncReturnType

      public boolean asyncReturnType()
      Returns the value of the asyncReturnType record component.
      Specified by:
      asyncReturnType in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the asyncReturnType record component
    • compilerGenerated

      public boolean compilerGenerated()
      Returns the value of the compilerGenerated record component.
      Returns:
      the value of the compilerGenerated record component
    • executionResultIgnored

      public boolean executionResultIgnored()
      Returns the value of the executionResultIgnored record component.
      Specified by:
      executionResultIgnored in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the executionResultIgnored record component
    • name

      @NonNull public @NonNull String name()
      Returns the value of the name record component.
      Specified by:
      name in interface eu.cloudnetservice.driver.base.Named
      Returns:
      the value of the name record component
    • returnType

      @NonNull public @NonNull Type returnType()
      Returns the value of the returnType record component.
      Specified by:
      returnType in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the returnType record component
    • unwrappedReturnType

      @NonNull public @NonNull Type unwrappedReturnType()
      Returns the value of the unwrappedReturnType record component.
      Returns:
      the value of the unwrappedReturnType record component
    • parameterTypes

      @NonNull public @NonNull Type[] parameterTypes()
      Returns the value of the parameterTypes record component.
      Specified by:
      parameterTypes in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the parameterTypes record component
    • methodType

      @NonNull public @NonNull MethodType methodType()
      Returns the value of the methodType record component.
      Specified by:
      methodType in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the methodType record component
    • definingClass

      @NonNull public @NonNull Class<?> definingClass()
      Returns the value of the definingClass record component.
      Specified by:
      definingClass in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the definingClass record component
    • executionTimeout

      @Nullable public @Nullable Duration executionTimeout()
      Returns the value of the executionTimeout record component.
      Specified by:
      executionTimeout in interface eu.cloudnetservice.driver.network.rpc.introspec.RPCMethodMetadata
      Returns:
      the value of the executionTimeout record component
    • chainMetadata

      Returns the value of the chainMetadata record component.
      Returns:
      the value of the chainMetadata record component