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.api.domain;
18  
19  import com.atlassian.jira.rest.client.api.IdentifiableEntity;
20  import com.atlassian.jira.rest.client.api.NamedEntity;
21  import com.google.common.base.Objects;
22  
23  /**
24   * JIRA issue field with its current value.
25   *
26   * @since v0.1
27   */
28  public class IssueField implements NamedEntity, IdentifiableEntity<String> {
29  
30  	private final String id;
31  	private final String name;
32  	private final String type;
33  	private final Object value;
34  
35  	public IssueField(String id, String name, String type, Object value) {
36  		this.id = id;
37  		this.name = name;
38  		this.type = type;
39  		this.value = value;
40  	}
41  
42  	public String getId() {
43  		return id;
44  	}
45  
46  	public String getName() {
47  		return name;
48  	}
49  
50  	public String getType() {
51  		return type;
52  	}
53  
54  	public Object getValue() {
55  		return value;
56  	}
57  
58  	@Override
59  	public String toString() {
60  		return Objects.toStringHelper(this).
61  				add("id", id).
62  				add("name", name).
63  				add("type", type).
64  				add("value", getValue()).
65  				toString();
66  	}
67  
68  	@Override
69  	public int hashCode() {
70  		return Objects.hashCode(id, name, type); // for the sake of performance we don't include "value" field here
71  	}
72  
73  	@Override
74  	public boolean equals(Object obj) {
75  		if (obj instanceof IssueField) {
76  			final IssueField that = (IssueField) obj;
77  			return Objects.equal(this.id, that.id)
78  					&& Objects.equal(this.name, that.name)
79  					&& Objects.equal(this.type, that.type)
80  					&& Objects.equal(this.value, that.value);
81  		}
82  		return false;
83  	}
84  
85  }