1 | /** |
2 | * |
3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
4 | * |
5 | * ==================================================================== |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * ==================================================================== |
18 | */ |
19 | package org.jclouds.cloudservers.domain; |
20 | |
21 | import java.util.Set; |
22 | |
23 | import com.google.common.collect.Sets; |
24 | import com.google.gson.annotations.SerializedName; |
25 | |
26 | /** |
27 | * |
28 | * @author Adrian Cole |
29 | */ |
30 | public class Addresses { |
31 | |
32 | @SerializedName("public") |
33 | private Set<String> publicAddresses = Sets.newLinkedHashSet(); |
34 | @SerializedName("private") |
35 | private Set<String> privateAddresses = Sets.newLinkedHashSet(); |
36 | |
37 | public Addresses() { |
38 | } |
39 | |
40 | public Addresses(Set<String> publicAddresses, Set<String> privateAddresses) { |
41 | this.publicAddresses = publicAddresses; |
42 | this.privateAddresses = privateAddresses; |
43 | } |
44 | |
45 | public void setPublicAddresses(Set<String> publicAddresses) { |
46 | this.publicAddresses = publicAddresses; |
47 | } |
48 | |
49 | public Set<String> getPublicAddresses() { |
50 | return publicAddresses; |
51 | } |
52 | |
53 | public void setPrivateAddresses(Set<String> privateAddresses) { |
54 | this.privateAddresses = privateAddresses; |
55 | } |
56 | |
57 | public Set<String> getPrivateAddresses() { |
58 | return privateAddresses; |
59 | } |
60 | |
61 | @Override |
62 | public String toString() { |
63 | return "Addresses [privateAddresses=" + privateAddresses + ", publicAddresses=" |
64 | + publicAddresses + "]"; |
65 | } |
66 | |
67 | @Override |
68 | public int hashCode() { |
69 | final int prime = 31; |
70 | int result = 1; |
71 | result = prime * result + ((privateAddresses == null) ? 0 : privateAddresses.hashCode()); |
72 | result = prime * result + ((publicAddresses == null) ? 0 : publicAddresses.hashCode()); |
73 | return result; |
74 | } |
75 | |
76 | @Override |
77 | public boolean equals(Object obj) { |
78 | if (this == obj) |
79 | return true; |
80 | if (obj == null) |
81 | return false; |
82 | if (getClass() != obj.getClass()) |
83 | return false; |
84 | Addresses other = (Addresses) obj; |
85 | if (privateAddresses == null) { |
86 | if (other.privateAddresses != null) |
87 | return false; |
88 | } else if (!privateAddresses.equals(other.privateAddresses)) |
89 | return false; |
90 | if (publicAddresses == null) { |
91 | if (other.publicAddresses != null) |
92 | return false; |
93 | } else if (!publicAddresses.equals(other.publicAddresses)) |
94 | return false; |
95 | return true; |
96 | } |
97 | |
98 | } |