EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.gogrid.domain]

COVERAGE SUMMARY FOR SOURCE FILE [Job.java]

nameclass, %method, %block, %line, %
Job.java100% (1/1)19%  (3/16)32%  (134/421)45%  (23.7/53)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Job100% (1/1)19%  (3/16)32%  (134/421)45%  (23.7/53)
compareTo (Job): int 0%   (0/1)0%   (0/20)0%   (0/3)
getAttempts (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getCommand (): Option 0%   (0/1)0%   (0/3)0%   (0/1)
getCreatedOn (): Date 0%   (0/1)0%   (0/3)0%   (0/1)
getCurrentState (): JobState 0%   (0/1)0%   (0/3)0%   (0/1)
getDetails (): Map 0%   (0/1)0%   (0/3)0%   (0/1)
getHistory (): Set 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): long 0%   (0/1)0%   (0/3)0%   (0/1)
getLastUpdatedOn (): Date 0%   (0/1)0%   (0/3)0%   (0/1)
getObjectType (): ObjectType 0%   (0/1)0%   (0/3)0%   (0/1)
getOwner (): String 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/122)0%   (0/11)
toString (): String 0%   (0/1)0%   (0/59)0%   (0/1)
equals (Object): boolean 100% (1/1)64%  (98/154)69%  (9.7/14)
Job (): void 100% (1/1)100% (3/3)100% (2/2)
Job (long, Option, ObjectType, Date, Date, JobState, int, String, SortedSet, ... 100% (1/1)100% (33/33)100% (12/12)

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 */
19package org.jclouds.gogrid.domain;
20 
21import java.util.Date;
22import java.util.Map;
23import java.util.Set;
24import java.util.SortedSet;
25 
26import com.google.common.primitives.Longs;
27import com.google.gson.annotations.SerializedName;
28 
29/**
30 * Represents any job in GoGrid system
31 * (jobs include server creation, stopping, etc)
32 *
33 * @see <a href="http://wiki.gogrid.com/wiki/index.php/API:Job_(Object)" />
34 * @author Oleksiy Yarmula
35 */
36public class Job implements Comparable<Job> {
37 
38    private long id;
39    private Option command;
40    @SerializedName("objecttype")
41    private ObjectType objectType;
42    @SerializedName("createdon")
43    private Date createdOn;
44    @SerializedName("lastupdatedon")
45    private Date lastUpdatedOn;
46    @SerializedName("currentstate")
47    private JobState currentState;
48    private int attempts;
49    private String owner;
50    private Set<JobProperties> history;
51    @SerializedName("detail") /*NOTE: as of Feb 28, 10,
52                                      there is a contradiction b/w the name in
53                                      documentation (details) and actual param
54                                      name (detail)*/
55    private Map<String, String> details;
56 
57    /**
58     * A no-args constructor is required for deserialization
59     */
60    public Job() {
61    }
62 
63    public Job(long id, Option command, ObjectType objectType,
64               Date createdOn, Date lastUpdatedOn, JobState currentState,
65               int attempts, String owner, SortedSet<JobProperties> history,
66               Map<String, String> details) {
67        this.id = id;
68        this.command = command;
69        this.objectType = objectType;
70        this.createdOn = createdOn;
71        this.lastUpdatedOn = lastUpdatedOn;
72        this.currentState = currentState;
73        this.attempts = attempts;
74        this.owner = owner;
75        this.history = history;
76        this.details = details;
77    }
78 
79    public long getId() {
80        return id;
81    }
82 
83    public Option getCommand() {
84        return command;
85    }
86 
87    public ObjectType getObjectType() {
88        return objectType;
89    }
90 
91    public Date getCreatedOn() {
92        return createdOn;
93    }
94 
95    public Date getLastUpdatedOn() {
96        return lastUpdatedOn;
97    }
98 
99    public JobState getCurrentState() {
100        return currentState;
101    }
102 
103    public int getAttempts() {
104        return attempts;
105    }
106 
107    public String getOwner() {
108        return owner;
109    }
110 
111    public Set<JobProperties> getHistory() {
112        return history;
113    }
114 
115    public Map<String, String> getDetails() {
116        return details;
117    }
118 
119    @Override
120    public boolean equals(Object o) {
121        if (this == o) return true;
122        if (o == null || getClass() != o.getClass()) return false;
123 
124        Job job = (Job) o;
125 
126        if (attempts != job.attempts) return false;
127        if (id != job.id) return false;
128        if (command != null ? !command.equals(job.command) : job.command != null) return false;
129        if (createdOn != null ? !createdOn.equals(job.createdOn) : job.createdOn != null) return false;
130        if (currentState != null ? !currentState.equals(job.currentState) : job.currentState != null) return false;
131        if (details != null ? !details.equals(job.details) : job.details != null) return false;
132        if (history != null ? !history.equals(job.history) : job.history != null) return false;
133        if (lastUpdatedOn != null ? !lastUpdatedOn.equals(job.lastUpdatedOn) : job.lastUpdatedOn != null) return false;
134        if (objectType != null ? !objectType.equals(job.objectType) : job.objectType != null) return false;
135        if (owner != null ? !owner.equals(job.owner) : job.owner != null) return false;
136 
137        return true;
138    }
139 
140    @Override
141    public int hashCode() {
142        int result = (int) (id ^ (id >>> 32));
143        result = 31 * result + (command != null ? command.hashCode() : 0);
144        result = 31 * result + (objectType != null ? objectType.hashCode() : 0);
145        result = 31 * result + (createdOn != null ? createdOn.hashCode() : 0);
146        result = 31 * result + (lastUpdatedOn != null ? lastUpdatedOn.hashCode() : 0);
147        result = 31 * result + (currentState != null ? currentState.hashCode() : 0);
148        result = 31 * result + attempts;
149        result = 31 * result + (owner != null ? owner.hashCode() : 0);
150        result = 31 * result + (history != null ? history.hashCode() : 0);
151        result = 31 * result + (details != null ? details.hashCode() : 0);
152        return result;
153    }
154 
155    @Override
156    public int compareTo(Job o) {
157        if(createdOn != null && o.getCreatedOn() != null)
158            return Longs.compare(createdOn.getTime(), o.getCreatedOn().getTime());
159        return Longs.compare(id, o.getId());
160    }
161 
162    @Override
163    public String toString() {
164        return "Job{" +
165                "id=" + id +
166                ", command=" + command +
167                ", objectType=" + objectType +
168                ", createdOn=" + createdOn +
169                ", lastUpdatedOn=" + lastUpdatedOn +
170                ", currentState=" + currentState +
171                ", attempts=" + attempts +
172                ", owner='" + owner + '\'' +
173                ", history=" + history +
174                ", details=" + details +
175                '}';
176    }
177}

[all classes][org.jclouds.gogrid.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov