Java Reflection Method Invoke invoke(Method method, Object javaBean, Object value)

Here you can find the source of invoke(Method method, Object javaBean, Object value)

Description

invoke

License

Open Source License

Parameter

Parameter Description
method a parameter
javaBean a parameter
value a parameter

Return

null

Declaration

public static Object invoke(Method method, Object javaBean, Object value) 

Method Source Code

//package com.java2s;
/************************************************************************************
 * @File name   :      ReflectionUtil.java
 *
 * @Author      :      JUNJZHU/* www .  j  a  v  a2s.  c om*/
 *
 * @Date        :      2012-11-16
 *
 * @Copyright Notice: 
 * Copyright (c) 2012 Shanghai OnStar, Inc. All  Rights Reserved.
 * This software is published under the terms of the Shanghai OnStar Software
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 * 
 * 
 * ----------------------------------------------------------------------------------
 * Date                        Who               Version            Comments
 * 2012-11-16 ????10:26:21         JUNJZHU         1.0            Initial Version
 ************************************************************************************/

import java.lang.reflect.Method;

public class Main {
    /**
     * @Author : XIAOXCHE
     * @Date : 2012-12-10
     * @param method
     * @param javaBean
     * @param value
     * @return null
     */
    public static Object invoke(Method method, Object javaBean, Object value) {
        Object[] paramValue = null;
        if (value == paramValue) {
            paramValue = new Object[0];
        } else {
            paramValue = new Object[] { value };
        }
        try {
            return method.invoke(javaBean, paramValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

  1. invoke(Method method)
  2. invoke(Method method)
  3. invoke(Method method, Object data, Object... arguments)
  4. invoke(Method method, Object instance, Object... parameters)
  5. invoke(Method method, Object it, Object... args)
  6. invoke(Method method, Object obj, Object... args)
  7. invoke(Method method, Object obj, Object... args)
  8. invoke(Method method, Object object, Object... args)
  9. invoke(Method method, Object object, Object... arguments)