com.github.andyshao.proxy.ProxyFactory Maven / Gradle / Ivy
package com.github.andyshao.proxy;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
import com.github.andyshao.util.Reflects;
/**
*
* Title:public proxy factory interface
* Descript:
* Copyright: Copryright(c) Mar 17, 2014
* Encoding:UNIX UTF-8
*
* @author Andy.Shao
*
* @param the type of target which will be proxy
*/
@FunctionalInterface
public interface ProxyFactory extends Function{
/**
* get the proxy
*
* @param target the target which will be proxy
* @return the proxy
*/
@Override
T apply(T target);
public static Class>[] allInterfaces(T target){
Set> set = new HashSet<>();
Reflects.superGetInterfaces(target.getClass() , set);
return set.toArray(new Class>[set.size()]);
}
public static String buildMethodKey(Method method){
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(method.getReturnType()).append(":");
stringBuilder.append(method.getName()).append(":");
stringBuilder.append(Arrays.toString(method.getParameterTypes()));
return stringBuilder.toString();
}
}