java深copy
使用工具类SerializationUtils
说明:由于org.apache.commons.lang3包提供,
AlarmDescDetailsDto r = SerializationUtils.clone(request);
r.setAlarmObjectType(AlarmObjectType.APPLICATION);
测试验证
AlarmDescDetailsDto request1 = new AlarmDescDetailsDto();
request1.setAlarmObjectType(AlarmObjectType.RESOURCE_GROUP_BY_APP_INSTANCE);
AlarmDescDetailsDto request2 = (AlarmDescDetailsDto) SerializationUtils.clone(request1);
request2.setAlarmObjectType(AlarmObjectType.APPLICATION);
log.info("request1:{}",JsonUtils.toJSONString(request1));
log.info("request2:{}",JsonUtils.toJSONString(request2));
结果
11:30:08.953 [main] INFO delta.d.D - request1:{"alarmRules":null,"notifyEnable":null,"notifyContactGroups":null,"notifyMethods":null,"resourceGroup":null,"updateUser":null,"includeAppMember":true,"includeErps":[],"excludeErps":[],"resourceIds":[],"name":null,"definition":null,"description":null,"alarmEnable":null,"resourceType":null,"resourceTypeCnName":null,"alarmObjectType":"RESOURCE_GROUP_BY_APP_INSTANCE","alarmObject":null,"alarmObjectPlatform":"UNKNOWN","resourcegroupName":null}
11:30:08.958 [main] INFO delta.d.D - request2:{"alarmRules":null,"notifyEnable":null,"notifyContactGroups":null,"notifyMethods":null,"resourceGroup":null,"updateUser":null,"includeAppMember":true,"includeErps":[],"excludeErps":[],"resourceIds":[],"name":null,"definition":null,"description":null,"alarmEnable":null,"resourceType":null,"resourceTypeCnName":null,"alarmObjectType":"APPLICATION","alarmObject":null,"alarmObjectPlatform":"UNKNOWN","resourcegroupName":null}
原创:做时间的朋友