Java Reflection Method Parameter getMethod(Class type, String name, Class... parameterTypes)

Here you can find the source of getMethod(Class type, String name, Class... parameterTypes)

Description

get Method

License

Mozilla Public License

Declaration

private static Optional<Method> getMethod(Class<?> type, String name, Class<?>... parameterTypes) 

Method Source Code

//package com.java2s;
/**/*from  ww w  . j a va2 s .  c o  m*/
 * Copyright (c) 2013-2016, The SeedStack authors <http://seedstack.org>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import java.lang.reflect.Method;

import java.util.Optional;

public class Main {
    private static Optional<Method> getMethod(Class<?> type, String name, Class<?>... parameterTypes) {
        try {
            return Optional.of(type.getDeclaredMethod(name, parameterTypes));
        } catch (NoSuchMethodException e) {
            return Optional.empty();
        }
    }
}

Related

  1. getMethod(Class instance, String method, Class... parameters)
  2. getMethod(Class sourceClass, boolean isFindDeclaredMethod, boolean isUpwardFind, String methodName, Class... methodParameterTypes)
  3. getMethod(Class target, String methodName, Class... parameterTypes)
  4. getMethod(Class type, String name, Class... parametersType)
  5. getMethod(Class type, String name, Class... parameterTypes)
  6. getMethod(Class clazz, String methodName, Class[] parameterTypes)
  7. getMethod(final Class clazz, final String name, final Class... parameterTypes)
  8. getMethod(final Class javaClass, final String methodName, final Class[] methodParameterTypes, final boolean shouldSetAccessible)
  9. getMethod(final Class aClass, final String methodName, Class[] parameterTypes)