1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.vcloud.domain.network.firewall;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 import javax.annotation.Nullable;
24
25
26
27
28
29
30
31 public class FirewallRule {
32
33 private final boolean enabled;
34 @Nullable
35 private final String description;
36 @Nullable
37 private final FirewallPolicy policy;
38 @Nullable
39 private final FirewallProtocols protocols;
40 private final int port;
41 private final String destinationIp;
42
43 public FirewallRule(boolean enabled, @Nullable String description, @Nullable FirewallPolicy policy,
44 @Nullable FirewallProtocols protocols, int port, String destinationIp) {
45 this.enabled = enabled;
46 this.description = description;
47 this.policy = policy;
48 this.protocols = protocols;
49 this.port = port;
50 this.destinationIp = checkNotNull(destinationIp, "destinationIp");
51 }
52
53
54
55
56 public boolean isEnabled() {
57 return enabled;
58 }
59
60
61
62
63 @Nullable
64 public String getDescription() {
65 return description;
66 }
67
68
69
70
71 @Nullable
72 public FirewallPolicy getPolicy() {
73 return policy;
74 }
75
76
77
78
79 @Nullable
80 public FirewallProtocols getProtocols() {
81 return protocols;
82 }
83
84
85
86
87
88 public int getPort() {
89 return port;
90 }
91
92
93
94
95
96 public String getDestinationIp() {
97 return destinationIp;
98 }
99
100 @Override
101 public int hashCode() {
102 final int prime = 31;
103 int result = 1;
104 result = prime * result + ((description == null) ? 0 : description.hashCode());
105 result = prime * result + ((destinationIp == null) ? 0 : destinationIp.hashCode());
106 result = prime * result + (enabled ? 1231 : 1237);
107 result = prime * result + ((policy == null) ? 0 : policy.hashCode());
108 result = prime * result + port;
109 result = prime * result + ((protocols == null) ? 0 : protocols.hashCode());
110 return result;
111 }
112
113 @Override
114 public boolean equals(Object obj) {
115 if (this == obj)
116 return true;
117 if (obj == null)
118 return false;
119 if (getClass() != obj.getClass())
120 return false;
121 FirewallRule other = (FirewallRule) obj;
122 if (description == null) {
123 if (other.description != null)
124 return false;
125 } else if (!description.equals(other.description))
126 return false;
127 if (destinationIp == null) {
128 if (other.destinationIp != null)
129 return false;
130 } else if (!destinationIp.equals(other.destinationIp))
131 return false;
132 if (enabled != other.enabled)
133 return false;
134 if (policy == null) {
135 if (other.policy != null)
136 return false;
137 } else if (!policy.equals(other.policy))
138 return false;
139 if (port != other.port)
140 return false;
141 if (protocols == null) {
142 if (other.protocols != null)
143 return false;
144 } else if (!protocols.equals(other.protocols))
145 return false;
146 return true;
147 }
148
149 @Override
150 public String toString() {
151 return "[description=" + description + ", destinationIp=" + destinationIp + ", enabled=" + enabled + ", policy="
152 + policy + ", port=" + port + ", protocols=" + protocols + "]";
153 }
154
155 }