paip.自定义java 泛型类与泛型方法的实现总结

paip.自定义java 泛型类与泛型方法的实现总结


============泛型方法
    public static <atiType,retType> retType reduceO4(atiType obj, Func function) {
         String lastVal="";
        if (obj instanceof List) {
            List objLi = (List) obj;
            for (int i = 0; i < objLi.size(); i++) {
                lastVal =   (String) function.invoke(lastVal, objLi.get(i));

            }
            return (retType) lastVal;
        }
        return null;
    }
    
    
     作者 老哇的爪子 Attilax 艾龙,  EMAIL:1466519819@qq.com
来源: http://blog.csdn.net/attilax

========泛型类
public abstract class tryX<t> {

    tryX curTryx;
    // private Logger loger;
    private String para1;

    /**
     * set default value
     * @param  
     * @return
     */
    public t $(t defaultValue) {
        this.defaultReturnValue = defaultValue;

        return this.itemWrap("");
    }


原文地址:https://www.cnblogs.com/attilax/p/15199263.html