code: public String rolesToYml(Collection<Role> roles) {
          try {
              Map<String, Role> map = new TreeMap<>();
              roles.forEach(role -> map.put(role.getKey(), role));
              return mapper.writeValueAsString(map);
          } catch (Exception e) {
              log.error("Failed to create roles YML file from collection, error: {}", e.getMessage(), e);
          }
          return null;
      }
docs: Convert roles collection to yml string.
  
  @param roles collection
  @return yml string