Мне нужно установить данные в сущности на основе некоторых условий.
Я использовал ниже для установки данных
if (StringUtils.isNotBlank(customerVO.getGender())) {
mstCustomer.setGender(customerVO.getGender());
}
if (StringUtils.isNotBlank(customerVO.getBirthDate())) {
mstCustomer.setDob(DateUtils.getUtilDate(customerVO.getBirthDate()));
}
if (StringUtils.isNotBlank(customerVO.getAdd1())) {
mstCustomer.setAddress1(customerVO.getAdd1());
}
if (StringUtils.isNotBlank(customerVO.getAdd2())) {
mstCustomer.setAddress2(customerVO.getAdd2());
}
if (StringUtils.isNotBlank(customerVO.getAdd3())) {
mstCustomer.setAddress3(customerVO.getAdd3());
}
if (StringUtils.isNotBlank(customerVO.getPincode())) {
mstCustomer.setPinCode(customerVO.getPincode());
}
if (StringUtils.isNotBlank(customerVO.getStateName())) {
MstState state = mstStateRepository.findByName(customerVO.getStateName());
mstCustomer.setMstState(state);
}
if (StringUtils.isNotBlank(customerVO.getCity())) {
MstCity city = mstCityRepository.findByName(customerVO.getCity());
mstCustomer.setMstCity(city);
}
if (StringUtils.isNotBlank(customerVO.getIdentificationType())) {
mstCustomer.setIdentificationType(customerVO.getIdentificationType());
}
if (StringUtils.isNotBlank(customerVO.getIdentificationData())) {
mstCustomer.setIdentificationData(customerVO.getIdentificationData());
}
MstStatus mstStatus = mstStatusRepository.findOne(MstStatusEnum.CUST_ACTIVE.getStatusCode());
if (mstStatus != null) {
mstCustomer.setMstStatus(mstStatus);
}
if (!StringUtils.isBlank(customerVO.getMaritalStatus())) {
mstCustomer.setMaritalStatus(customerVO.getMaritalStatus());
}
if (StringUtils.isBlank(customerVO.getWeddingAnniversary())) {
mstCustomer.setWeddingAnniversary(DateUtils.getDateFromString(customerVO.getWeddingAnniversary()));
}
if (StringUtils.isNotBlank(customerVO.getMotherTongue())) {
mstCustomer.setMotherTongue(customerVO.getMotherTongue());
}
if (StringUtils.isNotBlank(customerVO.getFamilySize())) {
mstCustomer.setFamilySize(Integer.valueOf(customerVO.getFamilySize()));
}
if (StringUtils.isNotBlank(customerVO.getAdultsSize())) {
mstCustomer.setAdultsSize(Integer.valueOf(customerVO.getAdultsSize()));
}
if (StringUtils.isNotBlank(customerVO.getNoOfKids())) {
mstCustomer.setNoOfKids(Integer.valueOf(customerVO.getNoOfKids()));
}
if (StringUtils.isNotBlank(customerVO.getChilddob1())) {
mstCustomer.setChilddob1(DateUtils.getDateFromString(customerVO.getChilddob1()));
}
if (StringUtils.isNotBlank(customerVO.getChilddob2())) {
mstCustomer.setChilddob2(DateUtils.getDateFromString(customerVO.getChilddob2()));
}
if (StringUtils.isNotBlank(customerVO.getProfession())) {
mstCustomer.setProfession(customerVO.getProfession());
}
Но сонар выбрасывает это исключение: Refactor this method to reduce its Cognitive Complexity from 27 to the 15 allowed.
Пожалуйста, представьте, какой способ лучше всего переработать над кодом.