protected String formatEntityList(LinkedHashSet<String> entities) {
    if (entities == null || entities.isEmpty()) {
      return "";
    }

    final StringBuilder formatted = new StringBuilder(StringUtils.join(entities, ", "));
    if (entities.size() > 1) {
      formatted.replace(formatted.lastIndexOf(","), formatted.lastIndexOf(",") + 1, " and");
    }

    return formatted.toString();
  }
Formats lists of given entities to human readable form:
[entity1] -> {entity1} {noun}
[entity1, entity2] -> {entity1} and {entity2} {noun}s
[entity1, entity2, entity3] -> {entity1}, {entity2} and {entity3} {noun}s
The noun for the entities is taken from check type, it may be cluster, service or host.

@param entities list of entities to format
@return formatted entity list
ambari-server/src/main/java/org/apache/ambari/server/checks/ClusterCheck.java