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