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.atlassian.jira.rest.client.api.domain.EntityHelper;
20  import com.google.common.base.Objects;
21  import com.google.common.collect.ImmutableList;
22  import com.google.common.collect.Maps;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  import java.util.Map;
27  
28  /**
29   * Represents new JIRA issue
30   *
31   * @since v1.0
32   */
33  public class IssueInput {
34  
35      private final Map<String, FieldInput> fields;
36      private final List<PropertyInput> properties;
37  
38      public static IssueInput createWithFields(FieldInput... fields) {
39          return new IssueInput(Maps.uniqueIndex(ImmutableList.copyOf(fields), EntityHelper.GET_ENTITY_STRING_ID_FUNCTION), new ArrayList<PropertyInput>());
40      }
41  
42      public IssueInput(Map<String, FieldInput> fields, List<PropertyInput> properties) {
43          this.fields = fields;
44          this.properties = properties;
45      }
46  
47      public Map<String, FieldInput> getFields() {
48          return fields;
49      }
50  
51      public List<PropertyInput> getProperties() {
52          return properties;
53      }
54  
55      @SuppressWarnings("unused")
56      public FieldInput getField(String id) {
57          return fields.get(id);
58      }
59  
60      @Override
61      public String toString() {
62          return Objects.toStringHelper(this)
63                  .add("fields", fields)
64                  .add("properties", properties)
65                  .toString();
66      }
67  }