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