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;
18  
19  import com.google.common.base.Function;
20  import com.google.common.collect.Collections2;
21  import com.google.common.collect.ImmutableList;
22  import com.google.common.collect.Iterables;
23  import com.google.common.collect.Lists;
24  
25  /**
26   * Keeps field id that may be used to refer to field in fields maps.
27   */
28  public enum IssueFieldId {
29  	AFFECTS_VERSIONS_FIELD("versions"),
30  	ASSIGNEE_FIELD("assignee"),
31  	ATTACHMENT_FIELD("attachment"),
32  	COMMENT_FIELD("comment"),
33  	COMPONENTS_FIELD("components"),
34  	CREATED_FIELD("created"),
35  	DESCRIPTION_FIELD("description"),
36  	DUE_DATE_FIELD("duedate"),
37  	FIX_VERSIONS_FIELD("fixVersions"),
38  	ISSUE_TYPE_FIELD("issuetype"),
39  	LABELS_FIELD("labels"),
40  	LINKS_FIELD("issuelinks"),
41  	LINKS_PRE_5_0_FIELD("links"),
42  	PRIORITY_FIELD("priority"),
43  	PROJECT_FIELD("project"),
44  	REPORTER_FIELD("reporter"),
45  	RESOLUTION_FIELD("resolution"),
46  	STATUS_FIELD("status"),
47  	SUBTASKS_FIELD("subtasks"),
48  	SUMMARY_FIELD("summary"),
49  	TIMETRACKING_FIELD("timetracking"),
50  	TRANSITIONS_FIELD("transitions"),
51  	UPDATED_FIELD("updated"),
52  	VOTES_FIELD("votes"),
53  	WATCHER_FIELD("watches"),
54  	WATCHER_PRE_5_0_FIELD("watcher"),
55  	WORKLOG_FIELD("worklog"),
56  	WORKLOGS_FIELD("worklogs");
57  
58  	public final String id;
59  
60  	IssueFieldId(String id) {
61  		this.id = id;
62  	}
63  
64  	public static final Function<IssueFieldId, String> TRANSFORM_TO_ID_FUNCTION = new Function<IssueFieldId, String>() {
65  		@Override
66  		public String apply(IssueFieldId from) {
67  			return from.id;
68  		}
69  	};
70  
71  	/**
72  	 * Returns all fields ids.
73  	 *
74  	 * @return List of string id of each field.
75  	 */
76  	public static Iterable<String> ids() {
77  		return Iterables.transform(Lists.newArrayList(IssueFieldId.values()), IssueFieldId.TRANSFORM_TO_ID_FUNCTION);
78  	}
79  }