Created
August 24, 2020 18:17
-
-
Save kirshiyin89/866397e58900d87a51082cf11c3640a7 to your computer and use it in GitHub Desktop.
The DataService.java processing the server info and mapping it to the final result.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public List<ServerInfo> getServerInfo() { | |
List<ServerInfo> result = new ArrayList<>(); | |
Map<String, String> serverData = getServerData(); | |
for (Map.Entry<String, String> info : serverData.entrySet()) { | |
result.add(new ServerInfo(info.getKey(), map(info.getValue()))); | |
} | |
return result; | |
} | |
private static List<ServiceInfo> map(String data) { | |
List<ServiceInfo> result = new ArrayList<>(); | |
if (!data.isEmpty() && !data.startsWith("error")) { | |
String[] split = data.split(","); | |
for (String service : split) { | |
String[] status = service.split(":"); | |
Boolean b = false; | |
if (Integer.valueOf(status[1])>0) { | |
b = true; | |
} | |
result.add(new ServiceInfo(status[0], b)); | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment