View Javadoc

1   /*
2    * Copyright (C) 2010 Atlassian
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.jira.rest.client.domain;
18  
19  import com.google.common.base.Objects;
20  import org.joda.time.DateTime;
21  
22  import javax.annotation.Nullable;
23  import java.net.URI;
24  
25  /**
26   * Issue worklog - single worklog entry describing the work logged for selected issue
27   *
28   * @since v0.1
29   */
30  public class Worklog {
31  	private final URI self;
32  	private final URI issueUri;
33  	private final BasicUser author;
34  	private final BasicUser updateAuthor;
35      @Nullable
36  	private final String comment;
37  	private final DateTime creationDate;
38  	private final DateTime updateDate;
39  	private final DateTime startDate;
40  	private final int minutesSpent;
41  	@Nullable
42  	private final Visibility visibility;
43  
44  	public Worklog(URI self, URI issueUri, BasicUser author, BasicUser updateAuthor, @Nullable String comment,
45                     DateTime creationDate, DateTime updateDate, DateTime startDate, int minutesSpent, Visibility visibility) {
46  		this.self = self;
47  		this.issueUri = issueUri;
48  		this.author = author;
49  		this.updateAuthor = updateAuthor;
50  		this.comment = comment;
51  		this.creationDate = creationDate;
52  		this.updateDate = updateDate;
53  		this.startDate = startDate;
54  		this.minutesSpent = minutesSpent;
55  		this.visibility = visibility;
56  	}
57  
58  	public URI getSelf() {
59  		return self;
60  	}
61  
62  	public URI getIssueUri() {
63  		return issueUri;
64  	}
65  
66  	public BasicUser getAuthor() {
67  		return author;
68  	}
69  
70  	public BasicUser getUpdateAuthor() {
71  		return updateAuthor;
72  	}
73  
74  	@Nullable
75      public String getComment() {
76  		return comment;
77  	}
78  
79  	public DateTime getCreationDate() {
80  		return creationDate;
81  	}
82  
83  	public DateTime getUpdateDate() {
84  		return updateDate;
85  	}
86  
87  	public DateTime getStartDate() {
88  		return startDate;
89  	}
90  
91  	public int getMinutesSpent() {
92  		return minutesSpent;
93  	}
94  
95  	public Visibility getVisibility() {
96  		return visibility;
97  	}
98  
99  	@Override
100 	public String toString() {
101 		return Objects.toStringHelper(this).
102 				add("self", self).
103 				add("issueUri", issueUri).
104 				add("author", author).
105 				add("updateAuthor", updateAuthor).
106 				add("comment", comment).
107 				add("creationDate", creationDate).
108 				add("updateDate", updateDate).
109 				add("startDate", startDate).
110 				add("minutesSpent", minutesSpent).
111 				add("visibility", visibility).
112 				toString();
113 	}
114 
115 	@Override
116 	public boolean equals(Object obj) {
117 		if (obj instanceof Worklog) {
118 			Worklog that = (Worklog) obj;
119 			return Objects.equal(this.self, that.self)
120 					&& Objects.equal(this.issueUri, that.issueUri)
121 					&& Objects.equal(this.author, that.author)
122 					&& Objects.equal(this.updateAuthor, that.updateAuthor)
123 					&& Objects.equal(this.comment, that.comment)
124 					&& Objects.equal(this.visibility, that.visibility)
125 					&& this.creationDate.isEqual(that.creationDate)
126 					&& this.updateDate.isEqual(that.updateDate)
127 					&& this.startDate.isEqual(that.startDate)
128 					&& Objects.equal(this.minutesSpent, that.minutesSpent);
129 		}
130 		return false;
131 	}
132 
133 	@Override
134 	public int hashCode() {
135 		return Objects.hashCode(self, issueUri, author, updateAuthor, comment, creationDate, updateDate, startDate, minutesSpent);
136 	}
137 
138 
139 }