// Path: src/main/java/io/taciturn/function/CheckedFunction.java
// @FunctionalInterface
// public interface CheckedFunction<T, R> {
// 
//     R apply(T t) throws Throwable;
// 
// }
// 
// Path: src/main/java/io/taciturn/function/Rethrower.java
// @SuppressWarnings("WeakerAccess")
// public class Rethrower {
// 
//     public static <T> T rethrow(CheckedCallable<T> callable) {
//         return rethrowFunction(o -> callable.call(), null);
//     }
// 
//     public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) {
//         rethrowFunction(o -> {
//             consumer.accept(o);
//             return (Void) null;
//         }, consumerParameter);
//     }
//     
//     public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) {
//         return Rethrower.rethrowFunction(function, functionParameter);
//     }
//     
//     public static void rethrow(Throwable throwable) {
//         Rethrower.rethrowCheckedThrowable(throwable);
//     }
// 
//     @SuppressWarnings("ConstantConditions")
//     private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) {
//         try {
//             return function.apply(functionParameter);
//         } catch (Throwable e) {
//             Rethrower.rethrow(e);
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     @SuppressWarnings({"unchecked", "ConstantConditions"})
//     private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T {
//         throw (T) throwable;
//     }
// 
// }
// 
// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.function.Predicate;
import io.taciturn.function.CheckedFunction;
import io.taciturn.function.Rethrower;
import static io.taciturn.Utility.$;
package io.taciturn.utility;




public class MethodUtility extends ObjectUtility<Method> {

    public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers());
    public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers());
    public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers());
    public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get");
    public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set");

    private final Object parent;

    public MethodUtility(Method object, Object parent) {
        super(object);
        this.parent = parent;
    }

    /**
     * @see Method#toString()
     */
    @Override
    public String toString() {
        return map(Method::toString).orElse(null);
    }

    /**
     * @see Method#invoke(Object, Object...)
     * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}.
     * @throws IllegalArgumentException
     * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}.
     */
    @SuppressWarnings({ "JavaDoc", "unchecked" })
    public <T> T invoke(Object... arguments) {
        return wrap(o -> (T) o.invoke(parent, arguments));
    }

    public void makeAccessible() {
// Path: src/main/java/io/taciturn/function/CheckedFunction.java
// @FunctionalInterface
// public interface CheckedFunction<T, R> {
// 
//     R apply(T t) throws Throwable;
// 
// }
// 
// Path: src/main/java/io/taciturn/function/Rethrower.java
// @SuppressWarnings("WeakerAccess")
// public class Rethrower {
// 
//     public static <T> T rethrow(CheckedCallable<T> callable) {
//         return rethrowFunction(o -> callable.call(), null);
//     }
// 
//     public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) {
//         rethrowFunction(o -> {
//             consumer.accept(o);
//             return (Void) null;
//         }, consumerParameter);
//     }
//     
//     public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) {
//         return Rethrower.rethrowFunction(function, functionParameter);
//     }
//     
//     public static void rethrow(Throwable throwable) {
//         Rethrower.rethrowCheckedThrowable(throwable);
//     }
// 
//     @SuppressWarnings("ConstantConditions")
//     private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) {
//         try {
//             return function.apply(functionParameter);
//         } catch (Throwable e) {
//             Rethrower.rethrow(e);
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     @SuppressWarnings({"unchecked", "ConstantConditions"})
//     private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T {
//         throw (T) throwable;
//     }
// 
// }
// 
// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


// Path: src/main/java/io/taciturn/utility/MethodUtility.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.function.Predicate;
import io.taciturn.function.CheckedFunction;
import io.taciturn.function.Rethrower;
import static io.taciturn.Utility.$;

package io.taciturn.utility;




public class MethodUtility extends ObjectUtility<Method> {

    public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers());
    public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers());
    public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers());
    public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get");
    public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set");

    private final Object parent;

    public MethodUtility(Method object, Object parent) {
        super(object);
        this.parent = parent;
    }

    /**
     * @see Method#toString()
     */
    @Override
    public String toString() {
        return map(Method::toString).orElse(null);
    }

    /**
     * @see Method#invoke(Object, Object...)
     * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}.
     * @throws IllegalArgumentException
     * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}.
     */
    @SuppressWarnings({ "JavaDoc", "unchecked" })
    public <T> T invoke(Object... arguments) {
        return wrap(o -> (T) o.invoke(parent, arguments));
    }

    public void makeAccessible() {
        ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) ||