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