Class MethodInformation

java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.MethodInformation

public class MethodInformation extends Object
Holds the full information about a specific method needed for rpc to work properly.
Since:
4.0
  • Field Details

    • name

      private final String name
    • returnType

      private final Type returnType
    • arguments

      private final Type[] arguments
    • voidMethod

      private final boolean voidMethod
    • sourceInstance

      private final Object sourceInstance
    • rawReturnType

      private final Class<?> rawReturnType
    • definingClass

      private final Class<?> definingClass
    • methodInvoker

      private final MethodInvoker methodInvoker
  • Constructor Details

  • Method Details

    • find

      @NonNull public static @NonNull MethodInformation find(@Nullable @Nullable Object instance, @NonNull @NonNull Class<?> sourceClass, @NonNull @NonNull String name, @Nullable @Nullable MethodInvokerGenerator generator, int argumentCount)
      Finds a method in the source class with the given name and argument count, throwing an exception if multiple methods are matching, or no method is matching. This method excludes all methods from the search which are annotated with @RPCIgnore.
      Parameters:
      instance - the instance to which the method should get bound or null if not bound.
      sourceClass - the class in which to search for the method.
      name - the name of the method to find.
      generator - the generator used for later method invoker generating, null if no generator is needed.
      argumentCount - the amount of arguments the target method must have to match.
      Returns:
      the information of the method matching the required properties.
      Throws:
      NullPointerException - if either the given source class or method name is null.
      CannotDecideException - if either none or multiple methods are matching the given filters.
    • name

      @NonNull public @NonNull String name()
      Get the name of the underlying method.
      Returns:
      the name of the underlying method.
    • returnType

      @NonNull public @NonNull Type returnType()
      Get the return type of the underlying method.
      Returns:
      the name of the underlying method.
    • rawReturnType

      @NonNull public @NonNull Class<?> rawReturnType()
      Get the raw return type of the underlying method. For example a method with a return type of Collection&lt;String&gt; would result in Collection.
      Returns:
      the raw return type of the method.
    • arguments

      public Type @NonNull [] arguments()
      Get the type of each argument the method has.
      Returns:
      the type of each argument the method has.
    • voidMethod

      public boolean voidMethod()
      Get if the method has a void return type.
      Returns:
      true if the method has a void return type, false otherwise.
    • sourceInstance

      public @UnknownNullability Object sourceInstance()
      Get the instance to which this method is bound, used for chained rpc call lookups to process on the instance returned by the previous rpc rather than a global one.
      Returns:
      the instance to which the method is bound, or null if not bound.
    • definingClass

      @NonNull public @NonNull Class<?> definingClass()
      Get the class in which the method is defined.
      Returns:
      the class in which the method is defined.
    • methodInvoker

      public @UnknownNullability MethodInvoker methodInvoker()
      Get a method invoker for the class, if generated. The invoker can only be generated during construction of this class not afterwards.
      Returns:
      a method invoker for the class, if generated.