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