Class MethodInformation
java.lang.Object
eu.cloudnetservice.driver.network.rpc.defaults.MethodInformation
Holds the full information about a specific method needed for rpc to work properly.
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the type of each argument the method has.Get the class in which the method is defined.static @NonNull MethodInformationfind(@Nullable Object instance, @NonNull Class<?> sourceClass, @NonNull String name, @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.Get a method invoker for the class, if generated.name()Get the name of the underlying method.Get the raw return type of the underlying method.Get the return type of the underlying method.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.booleanGet if the method has a void return type.
-
Field Details
-
name
-
returnType
-
arguments
-
voidMethod
private final boolean voidMethod -
sourceInstance
-
rawReturnType
-
definingClass
-
methodInvoker
-
-
Constructor Details
-
MethodInformation
protected MethodInformation(@NonNull @NonNull String name, @NonNull @NonNull Type rType, @NonNull @NonNull Type[] arguments, @Nullable @Nullable Object sourceInstance, @NonNull @NonNull Class<?> definingClass, @Nullable @Nullable MethodInvokerGenerator generator) Constructs a new method information instance.- Parameters:
name- the name of the method.rType- the return type of the method.arguments- the argument types of the method.sourceInstance- the original instance the method was located in or null if not bound.definingClass- the class in which the method is located.generator- the generator to use to make a method invoker or null if no method invoker is needed.- Throws:
NullPointerException- if one of the required constructor parameters is null.
-
-
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
Get the name of the underlying method.- Returns:
- the name of the underlying method.
-
returnType
Get the return type of the underlying method.- Returns:
- the name of the underlying method.
-
rawReturnType
Get the raw return type of the underlying method. For example a method with a return type ofCollection<String>would result inCollection.- Returns:
- the raw return type of the method.
-
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
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
Get the class in which the method is defined.- Returns:
- the class in which the method is defined.
-
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.
-