1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.savvis.vpdc.domain;
20
21 import org.jclouds.ovf.Section;
22
23
24
25
26
27 public class NetworkConnectionSection extends Section<NetworkConnectionSection> {
28
29 @SuppressWarnings("unchecked")
30 public static Builder builder() {
31 return new Builder();
32 }
33
34
35
36
37 @Override
38 public Builder toBuilder() {
39 return builder().fromNetworkConectionSection(this);
40 }
41
42 public static class Builder extends Section.Builder<NetworkConnectionSection> {
43 private String network;
44 private String ipAddress;
45
46 public Builder network(String network) {
47 this.network = network;
48 return this;
49 }
50
51 public Builder ipAddress(String ipAddress) {
52 this.ipAddress = ipAddress;
53 return this;
54 }
55
56
57
58
59 @Override
60 public NetworkConnectionSection build() {
61 return new NetworkConnectionSection(info, network, ipAddress);
62 }
63
64 public Builder fromNetworkConectionSection(NetworkConnectionSection in) {
65 return fromSection(in).network(in.getNetwork()).ipAddress(in.getIpAddress());
66 }
67
68
69
70
71 @Override
72 public Builder fromSection(Section<NetworkConnectionSection> in) {
73 return Builder.class.cast(super.fromSection(in));
74 }
75
76
77
78
79 @Override
80 public Builder info(String info) {
81 return Builder.class.cast(super.info(info));
82 }
83
84 }
85
86 private final String network;
87 private final String ipAddress;
88
89 public NetworkConnectionSection(String info, String network, String ipAddress) {
90 super(info);
91 this.network = network;
92 this.ipAddress = ipAddress;
93 }
94
95 public String getNetwork() {
96 return network;
97 }
98
99 public String getIpAddress() {
100 return ipAddress;
101 }
102
103 @Override
104 public int hashCode() {
105 final int prime = 31;
106 int result = super.hashCode();
107 result = prime * result + ((network == null) ? 0 : network.hashCode());
108 return result;
109 }
110
111 @Override
112 public boolean equals(Object obj) {
113 if (this == obj)
114 return true;
115 if (!super.equals(obj))
116 return false;
117 if (getClass() != obj.getClass())
118 return false;
119 NetworkConnectionSection other = (NetworkConnectionSection) obj;
120 if (network == null) {
121 if (other.network != null)
122 return false;
123 } else if (!network.equals(other.network))
124 return false;
125 return true;
126 }
127
128 @Override
129 public String toString() {
130 return String.format("[info=%s, network=%s, ipAddress=%s]", info, network, ipAddress);
131 }
132
133 }