try {
if(null==list||list.isEmpty()){
return null;
}
T t = null;
Method method;
Integer tid;
for (T temp : (List<T>)list) {
method = temp.getClass().getMethod("getUid", null);
tid = (Integer) method.invoke(temp, null);
if(tid==id){
t = temp;
break;
}
}
return t;
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}