| 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.gogrid.domain; |
| 20 | |
| 21 | import com.google.common.primitives.Longs; |
| 22 | import com.google.gson.annotations.SerializedName; |
| 23 | |
| 24 | import java.util.Date; |
| 25 | |
| 26 | /** |
| 27 | * State of a job. |
| 28 | * |
| 29 | * @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_State_(Object)"/> |
| 30 | * |
| 31 | * @author Oleksiy Yarmula |
| 32 | */ |
| 33 | public class JobProperties implements Comparable<JobProperties> { |
| 34 | |
| 35 | private long id; |
| 36 | @SerializedName("updatedon") |
| 37 | private Date updatedOn; |
| 38 | private JobState state; |
| 39 | private String note; |
| 40 | |
| 41 | /** |
| 42 | * A no-args constructor is required for deserialization |
| 43 | */ |
| 44 | public JobProperties() { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | public JobProperties(long id, Date updatedOn, JobState state, String note) { |
| 49 | this.id = id; |
| 50 | this.updatedOn = updatedOn; |
| 51 | this.state = state; |
| 52 | this.note = note; |
| 53 | } |
| 54 | |
| 55 | public long getId() { |
| 56 | return id; |
| 57 | } |
| 58 | |
| 59 | public Date getUpdatedOn() { |
| 60 | return updatedOn; |
| 61 | } |
| 62 | |
| 63 | public JobState getState() { |
| 64 | return state; |
| 65 | } |
| 66 | |
| 67 | public String getNote() { |
| 68 | return note; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public boolean equals(Object o) { |
| 73 | if (this == o) return true; |
| 74 | if (o == null || getClass() != o.getClass()) return false; |
| 75 | |
| 76 | JobProperties jobState = (JobProperties) o; |
| 77 | |
| 78 | if (id != jobState.id) return false; |
| 79 | if (note != null ? !note.equals(jobState.note) : jobState.note != null) return false; |
| 80 | if (state != null ? !state.equals(jobState.state) : jobState.state != null) return false; |
| 81 | if (updatedOn != null ? !updatedOn.equals(jobState.updatedOn) : jobState.updatedOn != null) return false; |
| 82 | |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public int hashCode() { |
| 88 | int result = (int) (id ^ (id >>> 32)); |
| 89 | result = 31 * result + (updatedOn != null ? updatedOn.hashCode() : 0); |
| 90 | result = 31 * result + (state != null ? state.hashCode() : 0); |
| 91 | result = 31 * result + (note != null ? note.hashCode() : 0); |
| 92 | return result; |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | public String toString() { |
| 97 | return "JobState{" + |
| 98 | "id=" + id + |
| 99 | ", updatedOn=" + updatedOn + |
| 100 | ", state=" + state + |
| 101 | ", note='" + note + '\'' + |
| 102 | '}'; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public int compareTo(JobProperties o) { |
| 107 | return Longs.compare(id, o.getId()); |
| 108 | } |
| 109 | } |