類名不同的類屬性值複製


            toMethod.invoke(to, new Object[] { value });
        }
    }

    /**
     * 從方法數組中獲取指定名稱的方法
     * 
     * @param methods
     * @param name
     * @return
     */
    public static Method findMethodByName(Method[] methods, String name) {

        for (int j = 0; j < methods.length; j++) {

            if (methods[j].getName().equals(name)) {

                return methods[j];
            }

        }
        return null;
    }

    public static void main(String[] args) {

        PBlackList from = new PBlackList();
        from.setPunTime(new Date());
        
        from.setAppPerName("方貴");
        
        from.setEffect(1);
        
        from.setAppPerNum("10102322");
        
        PBlackList targ = new PBlackList();
        String[] excut = new String[30];
         
        excut[0] = "apppernum";
        
        try {
            
            copyPropertiesExclude(from, targ, excut);

            System.out.println("日期:"+targ.getPunTime()+"-申請人:"+targ.getAppPerName()+"-有效:"+targ.getEffect()+"-編號:"+targ.getAppPerNum());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章