View Javadoc

1   /*
2    * Copyright (C) 2011 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.api.domain;
18  
19  import com.google.common.base.Objects;
20  
21  import javax.annotation.Nullable;
22  
23  /**
24   * Represents time tracking information associated with given issue
25   *
26   * @since com.atlassian.jira.rest.client.api 0.3, server 4.4
27   */
28  public class TimeTracking {
29      @Nullable
30      private final Integer originalEstimateMinutes;
31  
32      @Nullable
33      private final Integer remainingEstimateMinutes;
34      @Nullable
35      private final Integer timeSpentMinutes;
36  
37      public TimeTracking(@Nullable Integer originalEstimateMinutes, @Nullable Integer remainingEstimateMinutes, @Nullable Integer timeSpentMinutes) {
38          this.originalEstimateMinutes = originalEstimateMinutes;
39          this.remainingEstimateMinutes = remainingEstimateMinutes;
40          this.timeSpentMinutes = timeSpentMinutes;
41      }
42  
43      /**
44       * @return original estimation [in minutes] for this issue or <code>null</code> when time spent information is not available
45       */
46      @Nullable
47      public Integer getOriginalEstimateMinutes() {
48          return originalEstimateMinutes;
49      }
50  
51      /**
52       * @return original remaining estimated time [in minutes] for this issue or <code>null</code> when such estimation was not provided
53       */
54      @Nullable
55      public Integer getRemainingEstimateMinutes() {
56          return remainingEstimateMinutes;
57      }
58  
59      /**
60       * @return time spent [in minutes] on this issue or <code>null</code> when time spent information is not available to the caller
61       * (in some strange circumstances)
62       */
63      @Nullable
64      public Integer getTimeSpentMinutes() {
65          return timeSpentMinutes;
66      }
67  
68      @Override
69      public String toString() {
70          return Objects.toStringHelper(this).
71                  add("originalEstimateMinutes", originalEstimateMinutes).
72                  add("remainingEstimateMinutes", remainingEstimateMinutes).
73                  add("timeSpentMinutes", timeSpentMinutes).
74                  toString();
75      }
76  
77      @Override
78      public boolean equals(Object obj) {
79          if (obj instanceof TimeTracking) {
80              TimeTracking that = (TimeTracking) obj;
81              return Objects.equal(this.originalEstimateMinutes, that.originalEstimateMinutes)
82                      && Objects.equal(this.timeSpentMinutes, that.timeSpentMinutes)
83                      && Objects.equal(this.remainingEstimateMinutes, that.remainingEstimateMinutes);
84          }
85          return false;
86      }
87  
88      @Override
89      public int hashCode() {
90          return Objects.hashCode(originalEstimateMinutes, remainingEstimateMinutes, timeSpentMinutes);
91      }
92  
93  }