View Javadoc

1   /*
2    * Copyright (C) 2012 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 single item in Issue change history.
25   *
26   * @since 0.6
27   */
28  public class ChangelogItem {
29      private final FieldType fieldType;
30      private final String field;
31      private final String from;
32      private final String fromString;
33      private final String to;
34      private final String toString;
35  
36      public ChangelogItem(FieldType fieldType, String field, String from, String fromString, String to, String toString) {
37          this.fieldType = fieldType;
38          this.field = field;
39          this.from = from;
40          this.fromString = fromString;
41          this.to = to;
42          this.toString = toString;
43      }
44  
45      public FieldType getFieldType() {
46          return fieldType;
47      }
48  
49      public String getField() {
50          return field;
51      }
52  
53      @Nullable
54      public String getFrom() {
55          return from;
56      }
57  
58      @Nullable
59      public String getFromString() {
60          return fromString;
61      }
62  
63      @Nullable
64      public String getTo() {
65          return to;
66      }
67  
68      @Nullable
69      public String getToString() {
70          return toString;
71      }
72  
73      @Override
74      public boolean equals(Object obj) {
75          if (obj instanceof ChangelogItem) {
76              ChangelogItem that = (ChangelogItem) obj;
77              return Objects.equal(this.fieldType, that.fieldType)
78                      && Objects.equal(this.field, that.field)
79                      && Objects.equal(this.from, that.from)
80                      && Objects.equal(this.fromString, that.fromString)
81                      && Objects.equal(this.to, that.to)
82                      && Objects.equal(this.toString, that.toString);
83          }
84          return false;
85  
86      }
87  
88      @Override
89      public int hashCode() {
90          return Objects.hashCode(fieldType, field, from, fromString, to, toString);
91      }
92  
93      @Override
94      public String toString() {
95          return Objects.toStringHelper(this).
96                  add("fieldType", fieldType).
97                  add("field", field).
98                  add("from", from).
99                  add("fromString", fromString).
100                 add("to", to).
101                 add("toString", toString).
102                 toString();
103     }
104 
105 }