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.List; |
22 | |
23 | import com.google.common.collect.Lists; |
24 | |
25 | /** |
26 | * A shared IP group is a collection of servers that can share IPs with other members of the group. |
27 | * Any server in a group can share one or more public IPs with any other server in the group. With |
28 | * the exception of the first server in a shared IP group, servers must be launched into shared IP |
29 | * groups. A server may only be a member of one shared IP group. |
30 | * |
31 | * @author Adrian Cole |
32 | */ |
33 | public class SharedIpGroup { |
34 | |
35 | private int id; |
36 | private String name; |
37 | |
38 | private List<Integer> servers = Lists.newArrayList(); |
39 | |
40 | public SharedIpGroup() { |
41 | } |
42 | |
43 | public SharedIpGroup(int id, String name) { |
44 | this.id = id; |
45 | this.name = name; |
46 | } |
47 | |
48 | public void setId(int id) { |
49 | this.id = id; |
50 | } |
51 | |
52 | public int getId() { |
53 | return id; |
54 | } |
55 | |
56 | public void setName(String name) { |
57 | this.name = name; |
58 | } |
59 | |
60 | public String getName() { |
61 | return name; |
62 | } |
63 | |
64 | public void setServers(List<Integer> servers) { |
65 | this.servers = servers; |
66 | } |
67 | |
68 | public List<Integer> getServers() { |
69 | return servers; |
70 | } |
71 | |
72 | @Override |
73 | public int hashCode() { |
74 | final int prime = 31; |
75 | int result = 1; |
76 | result = prime * result + id; |
77 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
78 | result = prime * result + ((servers == null) ? 0 : servers.hashCode()); |
79 | return result; |
80 | } |
81 | |
82 | @Override |
83 | public boolean equals(Object obj) { |
84 | if (this == obj) |
85 | return true; |
86 | if (obj == null) |
87 | return false; |
88 | if (getClass() != obj.getClass()) |
89 | return false; |
90 | SharedIpGroup other = (SharedIpGroup) obj; |
91 | if (id != other.id) |
92 | return false; |
93 | if (name == null) { |
94 | if (other.name != null) |
95 | return false; |
96 | } else if (!name.equals(other.name)) |
97 | return false; |
98 | if (servers == null) { |
99 | if (other.servers != null) |
100 | return false; |
101 | } else if (!servers.equals(other.servers)) |
102 | return false; |
103 | return true; |
104 | } |
105 | |
106 | @Override |
107 | public String toString() { |
108 | return "SharedIpGroup [id=" + id + ", name=" + name + ", servers=" + servers + "]"; |
109 | } |
110 | |
111 | } |