Here you can find the source of getMethod(Class> clazz, String name, Class>... params)
Parameter | Description |
---|---|
clazz | The class to get the method for |
name | The name of the method |
params | The parameters of the method |
public static Optional<Method> getMethod(Class<?> clazz, String name, Class<?>... params)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.util.Optional; public class Main { /**/*from ww w .j a v a 2 s . c om*/ * @param clazz The class to get the method for * @param name The name of the method * @param params The parameters of the method * * @return The method, if any */ public static Optional<Method> getMethod(Class<?> clazz, String name, Class<?>... params) { try { return Optional.of(clazz.getMethod(name, params)); } catch (NoSuchMethodException ignored) { } try { return Optional.of(clazz.getDeclaredMethod(name, params)); } catch (NoSuchMethodException ignored) { } return Optional.empty(); } }