code: private static Collection<String> normalize(
        final Collection<String> rackNames, final boolean validateEnd) throws IllegalArgumentException {
  
      final List<String> normalizedRackNames = new ArrayList<>(rackNames.size());
  
      for (String rackName : rackNames) {
  
        rackName = rackName.trim();
        Validate.notEmpty(rackName, "Rack names cannot be empty");
  
        // should start with a separator
        if (!rackName.startsWith(Constants.RACK_PATH_SEPARATOR)) {
          rackName = Constants.RACK_PATH_SEPARATOR + rackName;
        }
  
        // remove the ending separator
        if (rackName.endsWith(Constants.RACK_PATH_SEPARATOR)) {
          rackName = rackName.substring(0, rackName.length() - 1);
        }
  
        if (validateEnd) {
          Validate.isTrue(!rackName.endsWith(Constants.ANY_RACK));
        }
  
        normalizedRackNames.add(rackName);
      }
  
      return normalizedRackNames;
    }
docs: Normalize rack names. Make sure that each rack name starts with a path separator /
  and does not have a path separator at the end. Also, if end validation is on, check
  that rack name does not end with a wildcard *.
  @param rackNames Collection of rack names to normalize.
  @param validateEnd If true, throw an exception if the name ends with ANY (*)
  @return Collection of normalized rack names.
  @throws IllegalArgumentException if validation of some rack names' fails.