diff --git a/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ClassDescription.java b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ClassDescription.java new file mode 100644 index 00000000..42dae809 --- /dev/null +++ b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ClassDescription.java @@ -0,0 +1,11 @@ +package com.github.kaktushose.jda.commands.definitions.description; + +import java.lang.annotation.Annotation; +import java.util.Collection; + +public record ClassDescription( + Class clazz, + String name, + Collection annotations, + Collection methods +) {} diff --git a/src/main/java/com/github/kaktushose/jda/commands/definitions/description/Descriptor.java b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/Descriptor.java new file mode 100644 index 00000000..b00e080f --- /dev/null +++ b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/Descriptor.java @@ -0,0 +1,6 @@ +package com.github.kaktushose.jda.commands.definitions.description; + +import java.util.function.Function; + +public interface Descriptor extends Function, ClassDescription> { +} diff --git a/src/main/java/com/github/kaktushose/jda/commands/definitions/description/MethodDescription.java b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/MethodDescription.java new file mode 100644 index 00000000..318b87f6 --- /dev/null +++ b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/MethodDescription.java @@ -0,0 +1,18 @@ +package com.github.kaktushose.jda.commands.definitions.description; + +import java.lang.annotation.Annotation; +import java.util.Collection; +import java.util.SequencedCollection; +import java.util.function.BiFunction; + +public record MethodDescription( + Class returnType, + String name, + Collection parameters, + Collection annotations, + BiFunction, Object> invoker +) { + public Object invoke(Object instance, SequencedCollection arguments) { + return invoker.apply(instance, arguments); + } +} diff --git a/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ParameterDescription.java b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ParameterDescription.java new file mode 100644 index 00000000..e55b071a --- /dev/null +++ b/src/main/java/com/github/kaktushose/jda/commands/definitions/description/ParameterDescription.java @@ -0,0 +1,10 @@ +package com.github.kaktushose.jda.commands.definitions.description; + +import java.lang.annotation.Annotation; +import java.util.Collection; + +public record ParameterDescription( + Class type, + Collection annotations +) { +} diff --git a/src/main/java/com/github/kaktushose/jda/commands/definitions/features/Invokeable.java b/src/main/java/com/github/kaktushose/jda/commands/definitions/features/Invokeable.java index b1ea73c4..3176c12e 100644 --- a/src/main/java/com/github/kaktushose/jda/commands/definitions/features/Invokeable.java +++ b/src/main/java/com/github/kaktushose/jda/commands/definitions/features/Invokeable.java @@ -1,12 +1,12 @@ package com.github.kaktushose.jda.commands.definitions.features; +import com.github.kaktushose.jda.commands.definitions.description.MethodDescription; import com.github.kaktushose.jda.commands.definitions.interactions.Interaction; import com.github.kaktushose.jda.commands.dispatching.context.InvocationContext; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.lang.reflect.Method; import java.util.SequencedCollection; public sealed interface Invokeable permits Replyable, Interaction { @@ -16,11 +16,11 @@ public sealed interface Invokeable permits Replyable, Interaction { default void invoke(@NotNull Object instance, @NotNull InvocationContext invocation) throws Throwable { SequencedCollection arguments = invocation.arguments(); - method().invoke(instance, arguments.toArray()); + method().invoke(instance, arguments); } @NotNull - Method method(); + MethodDescription method(); @NotNull SequencedCollection> methodSignature();