/**
* 通过反射改变更新状态
* @param obj
* @param filedName
* @return
*/
public RealmObject ReplaceAndUpdateBatch(RealmObject obj,String filedName,Object o){
//获取私有变量
Class clazz=obj.getClass();
Log.i("clazz","clazz========="+clazz);
try {
Field filed= clazz.getField(filedName);
// filed.setAccessible(true);
Class type=filed.getType();
Log.i("clazz","filed========="+type);
StringBuilder builder=new StringBuilder();
builder.append("set").append(filed.getName().substring(0,1).toUpperCase());
builder.append(filedName.substring(1,filedName.length()));
String methodName=builder.toString();
Log.i("clazz","methodName========="+methodName);
Method m=clazz.getMethod(methodName,type);
Log.i("clazz","filed========="+m.getName());
realm.beginTransaction();
m.invoke(obj,o);
realm.commitTransaction();
return obj;
} catch (NoSuchFieldException e) {
e.printStackTrace();
Log.i("clazz","NoSuchFieldException========="+e);
} catch (NoSuchMethodException e) {
e.printStackTrace();
Log.i("clazz","NoSuchMethodException========="+e);
} catch (InvocationTargetException e) {
e.printStackTrace();
Log.i("clazz","InvocationTargetException========="+e);
} catch (IllegalAccessException e) {
e.printStackTrace();
Log.i("clazz","IllegalAccessException========="+e);
}
return null;
}