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, @Nullable 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  	@Nullable
96  	public Visibility getVisibility() {
97  		return visibility;
98  	}
99  
100 	@Override
101 	public String toString() {
102 		return Objects.toStringHelper(this).
103 				add("self", self).
104 				add("issueUri", issueUri).
105 				add("author", author).
106 				add("updateAuthor", updateAuthor).
107 				add("comment", comment).
108 				add("creationDate", creationDate).
109 				add("updateDate", updateDate).
110 				add("startDate", startDate).
111 				add("minutesSpent", minutesSpent).
112 				add("visibility", visibility).
113 				toString();
114 	}
115 
116 	@Override
117 	public boolean equals(Object obj) {
118 		if (obj instanceof Worklog) {
119 			Worklog that = (Worklog) obj;
120 			return Objects.equal(this.self, that.self)
121 					&& Objects.equal(this.issueUri, that.issueUri)
122 					&& Objects.equal(this.author, that.author)
123 					&& Objects.equal(this.updateAuthor, that.updateAuthor)
124 					&& Objects.equal(this.comment, that.comment)
125 					&& Objects.equal(this.visibility, that.visibility)
126 					&& this.creationDate.isEqual(that.creationDate)
127 					&& this.updateDate.isEqual(that.updateDate)
128 					&& this.startDate.isEqual(that.startDate)
129 					&& Objects.equal(this.minutesSpent, that.minutesSpent);
130 		}
131 		return false;
132 	}
133 
134 	@Override
135 	public int hashCode() {
136 		return Objects.hashCode(self, issueUri, author, updateAuthor, comment, creationDate, updateDate, startDate, minutesSpent);
137 	}
138 
139 }