Код: Выделить всё
List json = new ArrayList()
def map = new HashMap()
def title = "Microservice1"
def uri = "https://someUrl.com/microservice1/api-docs"
map.put("name", title)
map.put("uri", uri)
json.push(map)
title = "Microservice2"
uri = "https://someUrl.com/microservice2/api-docs"
map.put("name", title)
map.put("url", uri)
json.push(map)
def api1 = "https://someApi1.com/api-docs"
def api2 = "https://someApi2.com/api-docs"
map = new HashMap()
map.put("name", "API 1")
map.put("url", api1)
json.push(map)
map = new HashMap()
map.put("name", "API 2")
map.put("url", api2)
json.push(map)
map = new HashMap()
map.put("name", "Leads")
map.put("url", api2 + "?groups=Leads")
json.push(map)
// What exactly does this do?
Collections.sort(json, new Comparator() {
public int compare(Map m1, Map m2) {
return m1.get("name").compareTo(m2.get("name"));
}
});
Подробнее здесь: https://stackoverflow.com/questions/785 ... gorithm-do
Мобильная версия