Refactor multiple If' statements in Java-8
问题 I need to validate mandatory fields in my class For example, 9 fields must not be null . I need to check if they are all null but I am using multiple if statements for this now as below: StringBuilder mandatoryExcessFields = new StringBuilder(MANDATORY_EXCESS_FIELDS.length); if(Objects.isNull(excess.getAsOfDate())){ mandatoryExcessFields.append(MANDATORY_EXCESS_FIELDS[0]); } if(StringUtils.isEmpty(excess.getStatus())) { mandatoryExcessFields.append(MANDATORY_EXCESS_FIELDS[1]); } if(Objects