Here you can find the source of invokeGetterMethod(final Method method, final Object object)
Parameter | Description |
---|---|
method | to invoke |
object | that has the method |
Parameter | Description |
---|---|
IllegalArgumentException | if the method cannot be invoked |
public static Object invokeGetterMethod(final Method method, final Object object)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Main { /**//from ww w.j a v a 2s .co m * Invokes the supplied method on the supplied object. * * @param method to invoke * @param object that has the method * * @return value of the invoked method * * @throws IllegalArgumentException if the method cannot be invoked */ public static Object invokeGetterMethod(final Method method, final Object object) { try { return method.invoke(object); } catch (IllegalAccessException | InvocationTargetException e) { throw new IllegalArgumentException(e); } } }