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.input;
18
19 import com.atlassian.jira.rest.client.api.IdentifiableEntity;
20 import com.atlassian.jira.rest.client.api.domain.IssueFieldId;
21 import com.google.common.base.Objects;
22
23 /**
24 * New value for selected field - used while changing issue fields - e.g. while transitioning issue.
25 *
26 * @since v0.1
27 */
28 public class FieldInput implements IdentifiableEntity<String> {
29 private final String id;
30 private final Object value;
31
32 /**
33 * @param id field id
34 * @param value new value for this issue field
35 */
36 public FieldInput(String id, Object value) {
37 this.id = id;
38 this.value = value;
39 }
40
41 /**
42 * @param field issue field
43 * @param value new value for this issue field
44 */
45 public FieldInput(IssueFieldId field, Object value) {
46 this.id = field.id;
47 this.value = value;
48 }
49
50 /**
51 * @return field id
52 */
53 public String getId() {
54 return id;
55 }
56
57 /**
58 * @return new value for this issue field
59 */
60 public Object getValue() {
61 return value;
62 }
63
64 @Override
65 public int hashCode() {
66 return Objects.hashCode(id, value);
67 }
68
69 @Override
70 public boolean equals(Object obj) {
71 if (obj instanceof FieldInput) {
72 final FieldInput other = (FieldInput) obj;
73 return Objects.equal(this.id, other.id)
74 && Objects.equal(this.value, other.value);
75 }
76 return false;
77 }
78
79 @Override
80 public String toString() {
81 return Objects.toStringHelper(this)
82 .add("id", id)
83 .add("value", value)
84 .toString();
85 }
86 }