使用工具类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}
标签:SerializationUtils,AlarmDescDetailsDto,copy,java,APPLICATION,request2,request1,n
From: https://www.cnblogs.com/PythonOrg/p/17956223