View Javadoc

1   /*
2    * Copyright (C) 2010 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.Objects;
20  
21  import javax.annotation.Nullable;
22  import java.net.URI;
23  
24  /**
25   * Project component
26   *
27   * @since v0.1
28   */
29  public class Component extends BasicComponent {
30  	private final BasicUser lead;
31  
32  	@Nullable
33  	private AssigneeInfo assigneeInfo;
34  
35  
36  	public Component(URI self, @Nullable Long id, String name, String description, BasicUser lead) {
37  		super(self, id, name, description);
38  		this.lead = lead;
39  	}
40  
41  	public Component(URI self, @Nullable Long id, String name, String description, BasicUser lead, @Nullable AssigneeInfo assigneeInfo) {
42  		this(self, id, name, description, lead);
43  		this.assigneeInfo = assigneeInfo;
44  	}
45  
46  	public BasicUser getLead() {
47  		return lead;
48  	}
49  
50  	/**
51  	 * @return detailed info about auto-assignee for this project component or <code>null</code> if such information is
52  	 *         not available (JIRA prior 4.4)
53  	 * @since com.atlassian.jira.rest.client.api 0.3, server 4.4
54  	 */
55  	@Nullable
56  	public AssigneeInfo getAssigneeInfo() {
57  		return assigneeInfo;
58  	}
59  
60  	@Override
61  	public String toString() {
62  		return Objects.toStringHelper(this).addValue(super.toString()).
63  				add("lead", lead).
64  				add("assigneeInfo", assigneeInfo).
65  				toString();
66  	}
67  
68  
69  	@Override
70  	public boolean equals(Object obj) {
71  		if (obj instanceof Component) {
72  			Component that = (Component) obj;
73  			return super.equals(obj) && Objects.equal(this.lead, that.lead)
74  					&& Objects.equal(this.assigneeInfo, that.assigneeInfo);
75  		}
76  		return false;
77  	}
78  
79  	@Override
80  	public int hashCode() {
81  		return Objects.hashCode(super.hashCode(), lead, assigneeInfo);
82  	}
83  
84  	public static class AssigneeInfo {
85  		@Nullable
86  		private final BasicUser assignee;
87  		private final AssigneeType assigneeType;
88  		@Nullable
89  		private final BasicUser realAssignee;
90  		private final AssigneeType realAssigneeType;
91  		private final boolean isAssigneeTypeValid;
92  
93  		public AssigneeInfo(BasicUser assignee, AssigneeType assigneeType, @Nullable BasicUser realAssignee, AssigneeType realAssigneeType, boolean assigneeTypeValid) {
94  			this.assignee = assignee;
95  			this.assigneeType = assigneeType;
96  			this.realAssignee = realAssignee;
97  			this.realAssigneeType = realAssigneeType;
98  			isAssigneeTypeValid = assigneeTypeValid;
99  		}
100 
101 		@Nullable
102 		public BasicUser getAssignee() {
103 			return assignee;
104 		}
105 
106 		public AssigneeType getAssigneeType() {
107 			return assigneeType;
108 		}
109 
110 		@Nullable
111 		public BasicUser getRealAssignee() {
112 			return realAssignee;
113 		}
114 
115 		public AssigneeType getRealAssigneeType() {
116 			return realAssigneeType;
117 		}
118 
119 		public boolean isAssigneeTypeValid() {
120 			return isAssigneeTypeValid;
121 		}
122 
123 		@Override
124 		public String toString() {
125 			return Objects.toStringHelper(this).
126 					add("assignee", assignee).
127 					add("assigneeType", assigneeType).
128 					add("realAssignee", realAssignee).
129 					add("realAssigneeType", realAssigneeType).
130 					add("isAssigneeTypeValid", isAssigneeTypeValid).
131 					toString();
132 		}
133 
134 
135 		@Override
136 		public boolean equals(Object obj) {
137 			if (obj instanceof AssigneeInfo) {
138 				AssigneeInfo that = (AssigneeInfo) obj;
139 				return Objects.equal(this.assignee, that.assignee)
140 						&& Objects.equal(this.assigneeType, that.assigneeType)
141 						&& Objects.equal(this.realAssignee, that.realAssignee)
142 						&& Objects.equal(this.realAssigneeType, that.realAssigneeType)
143 						&& Objects.equal(this.isAssigneeTypeValid, that.isAssigneeTypeValid);
144 			}
145 			return false;
146 		}
147 
148 		@Override
149 		public int hashCode() {
150 			return Objects.hashCode(super
151 					.hashCode(), assignee, assigneeType, realAssignee, realAssigneeType, isAssigneeTypeValid);
152 		}
153 
154 	}
155 }