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 | /** |
22 | * A backup schedule can be defined to create server images at regular intervals (daily and weekly). |
23 | * Backup schedules are configurable per server. |
24 | * |
25 | * @author Adrian Cole |
26 | */ |
27 | public class BackupSchedule { |
28 | protected DailyBackup daily = DailyBackup.DISABLED; |
29 | protected boolean enabled; |
30 | protected WeeklyBackup weekly = WeeklyBackup.DISABLED; |
31 | |
32 | public BackupSchedule() { |
33 | } |
34 | |
35 | public BackupSchedule(WeeklyBackup weekly, DailyBackup daily, boolean enabled) { |
36 | this.weekly = weekly; |
37 | this.daily = daily; |
38 | this.enabled = enabled; |
39 | } |
40 | |
41 | public DailyBackup getDaily() { |
42 | return daily; |
43 | } |
44 | |
45 | public void setDaily(DailyBackup value) { |
46 | this.daily = value; |
47 | } |
48 | |
49 | public boolean isEnabled() { |
50 | return enabled; |
51 | } |
52 | |
53 | public void setEnabled(boolean value) { |
54 | this.enabled = value; |
55 | } |
56 | |
57 | public WeeklyBackup getWeekly() { |
58 | return weekly; |
59 | } |
60 | |
61 | public void setWeekly(WeeklyBackup value) { |
62 | this.weekly = value; |
63 | } |
64 | |
65 | @Override |
66 | public String toString() { |
67 | return "BackupSchedule [daily=" + daily + ", enabled=" + enabled + ", weekly=" + weekly + "]"; |
68 | } |
69 | |
70 | @Override |
71 | public int hashCode() { |
72 | final int prime = 31; |
73 | int result = 1; |
74 | result = prime * result + ((daily == null) ? 0 : daily.hashCode()); |
75 | result = prime * result + (enabled ? 1231 : 1237); |
76 | result = prime * result + ((weekly == null) ? 0 : weekly.hashCode()); |
77 | return result; |
78 | } |
79 | |
80 | @Override |
81 | public boolean equals(Object obj) { |
82 | if (this == obj) |
83 | return true; |
84 | if (obj == null) |
85 | return false; |
86 | if (getClass() != obj.getClass()) |
87 | return false; |
88 | BackupSchedule other = (BackupSchedule) obj; |
89 | if (daily == null) { |
90 | if (other.daily != null) |
91 | return false; |
92 | } else if (!daily.equals(other.daily)) |
93 | return false; |
94 | if (enabled != other.enabled) |
95 | return false; |
96 | if (weekly == null) { |
97 | if (other.weekly != null) |
98 | return false; |
99 | } else if (!weekly.equals(other.weekly)) |
100 | return false; |
101 | return true; |
102 | } |
103 | |
104 | } |