forked from vmware/flowgate
/
InfoBloxIPInfoResult.java
73 lines (59 loc) · 2.02 KB
/
InfoBloxIPInfoResult.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.vmware.flowgate.infobloxworker.model;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
public class InfoBloxIPInfoResult implements Serializable {
private String hostName;
private String ipAddress;
private String macAddress;
public InfoBloxIPInfoResult() {
}
public static InfoBloxIPInfoResult build(String hostName, Infoblox infoblox) {
InfoBloxIPInfoResult infoBloxIPInfoResult = new InfoBloxIPInfoResult();
final String ipAddress = infoblox.getIpAddress();
final String macAddress;
final String hostNameWithoutZone;
if (StringUtils.isNotBlank(infoblox.getMacAddress())) {
macAddress = infoblox.getMacAddress();
} else if (infoblox.getDiscoveredData() != null && StringUtils.isNotBlank(infoblox.getDiscoveredData().getMacAddress())) {
macAddress = infoblox.getDiscoveredData().getMacAddress();
} else {
macAddress = null;
}
int index = hostName.indexOf(".");
if (index > 0) {
hostNameWithoutZone = hostName.substring(0, index);
} else {
hostNameWithoutZone = hostName;
}
infoBloxIPInfoResult.setIpAddress(ipAddress);
infoBloxIPInfoResult.setMacAddress(macAddress);
infoBloxIPInfoResult.setHostName(hostNameWithoutZone);
return infoBloxIPInfoResult;
}
public String getHostName() {
return hostName;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public String getMacAddress() {
return macAddress;
}
public void setMacAddress(String macAddress) {
this.macAddress = macAddress;
}
@Override
public String toString() {
return "InfoBloxResult{" +
"hostName='" + hostName + '\'' +
", ipAddress='" + ipAddress + '\'' +
", macAddress='" + macAddress + '\'' +
'}';
}
}