I have a function and Technical Leader review code and said : Why this if statement? It's basically the same message. If you want customized, use a string builder with the type. How to change it , can someone help me?
private Optional<String> validatePrimaryPath(SalesChannelType salesChannelCode, List<String> primaryPathList) {
if (CollectionUtils.isEmpty(primaryPathList)) {
if (salesChannelCode.equals(SalesChannelType.HEB_TO_YOU)) {
return Optional.of("Customer Hierarchy is mandatory field for HebToYou.");
} else {
return Optional.of("Customer Hierarchy is mandatory field.");
}
}
return Optional.empty();
}