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.input;
18  
19  import com.google.common.base.Objects;
20  import com.google.common.collect.ImmutableMap;
21  
22  import java.util.Map;
23  
24  /**
25   * Represents object with fields in IssueInputField's value.
26   *
27   * @since v1.0
28   */
29  public class ComplexIssueInputFieldValue {
30  
31      private final Map<String, Object> valuesMap;
32  
33      public static ComplexIssueInputFieldValue with(String key, Object value) {
34          return new ComplexIssueInputFieldValue(ImmutableMap.<String, Object>of(key, value));
35      }
36  
37      public ComplexIssueInputFieldValue(Map<String, Object> valuesMap) {
38          this.valuesMap = valuesMap;
39      }
40  
41      public Map<String, Object> getValuesMap() {
42          return valuesMap;
43      }
44  
45      @Override
46      public String toString() {
47          return Objects.toStringHelper(this)
48                  .add("valuesMap", valuesMap)
49                  .toString();
50      }
51  
52      @Override
53      public int hashCode() {
54          return Objects.hashCode(valuesMap);
55      }
56  
57      @Override
58      public boolean equals(Object obj) {
59          if (obj instanceof ComplexIssueInputFieldValue) {
60              final ComplexIssueInputFieldValue other = (ComplexIssueInputFieldValue) obj;
61              return Objects.equal(this.valuesMap, other.valuesMap);
62          }
63          return false;
64      }
65  }