private static void maybeFillLinks(TaskConfig task) { if (task.getTaskLinksSize() == 0) { ImmutableMap.Builder<String, String> links = ImmutableMap.builder(); if (task.getRequestedPorts().contains("health")) { links.put("health", "http://%host%:%port:health%"); } if (task.getRequestedPorts().contains("http")) { links.put("http", "http://%host%:%port:http%"); } task.setTaskLinks(links.build()); } }