Package cn.com.refects

Source Code of cn.com.refects.MockInstanceCreator

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.com.refects;

import cn.com.refects.handler.MockInvocationHandler;
import cn.com.utils.DataProviderConfig;
import cn.com.utils.DataProviderConfig.DataProviderModel;
import java.lang.reflect.Proxy;

/**
*
* @author kete
*/
public class MockInstanceCreator {

    /**
     * 获取mock实类
     * @param clazz
     * @return
     */
    public static Object instance(Class<?> clazz, DataProviderModel model) {

        return Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new MockInvocationHandler(model));
    }

    /**
     * 获取mock实类
     * @param clazz
     * @param parameters
     * @return
     */
    public static Object instance(Class<?> clazz, Object parameters) {

        return instance(clazz, DataProviderConfig.INSTANCE.getProviderModel());
    }

    /**
     * 获取mock实类
     * @param clazz
     * @param parameters
     * @return
     */
    public static Object instance(Class<?> clazz, Object parameters, DataProviderModel model) {

        return instance(clazz, model);
    }
}
TOP

Related Classes of cn.com.refects.MockInstanceCreator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.