package com.runesuite.client.game.raw;

import org.jetbrains.annotations.NotNull;

import java.util.Arrays;

/**
 * An event representing a point in the execution of a method.
 *
 * @param <I> the instance type the method is declared on, {@link Void} for {@code static} methods
 */
public interface MethodEvent<I> {

    long getId();

    /**
     * The instance the method was called on, {@code null} for {@code static} methods.
     */
    I getInstance();

    /**
     * The arguments used to call the method, boxing primitive values. Should not be modified.
     */
    Object[] getArguments();

    /**
     * An event representing the entrance to a method.
     *
     * @param <I> the instance type the method is declared on, {@link Void} for {@code static} methods
     */
    interface Enter<I> extends MethodEvent<I> {

    }

    /**
     * An event representing the exit from a method.
     *
     * @param <I> the instance type the method is declared on, {@link Void} for {@code static} methods
     * @param <R> the return type of the method, wrappers for primitives, {@link Void} for {@code void} methods
     */
    interface Exit<I, R> extends MethodEvent<I> {

        /**
         * The value returned from the method, boxing primitives, {@code null} for {@code void} methods.
         */
        R getReturned();
    }

    /**
     * For internal use only.
     */
    class Implementation<I, R> implements MethodEvent.Enter<I>, MethodEvent.Exit<I, R> {

        public final long id;

        public final I instance;

        @NotNull
        public final Object[] arguments;

        public R returned;

        public Implementation(long id, I instance, @NotNull Object[] arguments) {
            this.id = id;
            this.instance = instance;
            this.arguments = arguments;
        }

        @Override
        public long getId() {
            return id;
        }

        @Override
        public I getInstance() {
            return instance;
        }

        @NotNull
        @Override
        public Object[] getArguments() {
            return arguments;
        }

        @Override
        public R getReturned() {
            return returned;
        }
    }
}
@@ -2199,16 +2199,334 @@
        %7D
+%0A%0A        @Override%0A        public String toString() %7B%0A            return %22MethodEvent(%22 +%0A                    %22id=%22 + id +%0A                    %22, instance=%22 + instance +%0A                    %22, arguments=%22 + Arrays.toString(arguments) +%0A                    %22, returned=%22 + returned +%0A                    ')';%0A        %7D
 %0A    %7D%0A%7D

Add MethodEvent.Implementation toString()