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.domain.input;
18  
19  import com.atlassian.jira.rest.client.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.Map;
25  
26  /**
27   * Represents new JIRA issue
28   *
29   * @since v1.0
30   */
31  public class IssueInput {
32  
33  	private final Map<String, FieldInput> fields;
34  
35  	public static IssueInput createWithFields(FieldInput ... fields) {
36  		return new IssueInput(Maps.uniqueIndex(ImmutableList.copyOf(fields), EntityHelper.GET_ENTITY_STRING_ID_FUNCTION));
37  	}
38  
39  	public IssueInput(Map<String, FieldInput> fields) {
40  		this.fields = fields;
41  	}
42  
43  	public Map<String, FieldInput> getFields() {
44  		return fields;
45  	}
46  
47  	@SuppressWarnings("unused")
48  	public FieldInput getField(String id) {
49  		return fields.get(id);
50  	}
51  
52  	@Override
53  	public String toString() {
54  		return Objects.toStringHelper(this)
55  				.add("fields", fields)
56  				.toString();
57  	}
58  }