1 | /** |
2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
3 | * contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. jclouds licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. 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, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | package org.jclouds.slicehost.domain; |
20 | |
21 | import java.util.Date; |
22 | |
23 | /** |
24 | * |
25 | * |
26 | * @author Adrian Cole |
27 | */ |
28 | public class Backup { |
29 | |
30 | private final int id; |
31 | private final String name; |
32 | private final String sliceId; |
33 | private final Date date; |
34 | |
35 | public Backup(int id, String name, String sliceId, Date date) { |
36 | this.id = id; |
37 | this.name = name; |
38 | this.sliceId = sliceId; |
39 | this.date = date; |
40 | } |
41 | |
42 | /** |
43 | * @return id of the backup |
44 | */ |
45 | public int getId() { |
46 | return id; |
47 | } |
48 | |
49 | /** |
50 | * @return Examples: weekly, my snapshot |
51 | */ |
52 | public String getName() { |
53 | return name; |
54 | } |
55 | |
56 | /** |
57 | * @return The Slice this backup was made from |
58 | */ |
59 | public String getSliceId() { |
60 | return sliceId; |
61 | } |
62 | |
63 | /** |
64 | * @return The time the backup was taken |
65 | */ |
66 | public Date getDate() { |
67 | return date; |
68 | } |
69 | |
70 | @Override |
71 | public int hashCode() { |
72 | final int prime = 31; |
73 | int result = 1; |
74 | result = prime * result + ((date == null) ? 0 : date.hashCode()); |
75 | result = prime * result + id; |
76 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
77 | result = prime * result + ((sliceId == null) ? 0 : sliceId.hashCode()); |
78 | return result; |
79 | } |
80 | |
81 | @Override |
82 | public boolean equals(Object obj) { |
83 | if (this == obj) |
84 | return true; |
85 | if (obj == null) |
86 | return false; |
87 | if (getClass() != obj.getClass()) |
88 | return false; |
89 | Backup other = (Backup) obj; |
90 | if (date == null) { |
91 | if (other.date != null) |
92 | return false; |
93 | } else if (!date.equals(other.date)) |
94 | return false; |
95 | if (id != other.id) |
96 | return false; |
97 | if (name == null) { |
98 | if (other.name != null) |
99 | return false; |
100 | } else if (!name.equals(other.name)) |
101 | return false; |
102 | if (sliceId == null) { |
103 | if (other.sliceId != null) |
104 | return false; |
105 | } else if (!sliceId.equals(other.sliceId)) |
106 | return false; |
107 | return true; |
108 | } |
109 | |
110 | @Override |
111 | public String toString() { |
112 | return "[date=" + date + ", id=" + id + ", name=" + name + ", sliceId=" + sliceId + "]"; |
113 | } |
114 | |
115 | } |