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.atlassian.jira.rest.client.AddressableEntity;
20  import com.atlassian.jira.rest.client.IdentifiableEntity;
21  import com.atlassian.jira.rest.client.NamedEntity;
22  import com.google.common.base.Objects;
23  
24  import javax.annotation.Nullable;
25  import java.net.URI;
26  
27  /**
28   * Basic information about issue type.
29   *
30   * @since v0.1
31   */
32  public class BasicIssueType implements AddressableEntity, NamedEntity, IdentifiableEntity<Long> {
33  	private final URI self;
34  
35  	@Nullable
36  	private final Long id;
37  
38  	private final String name;
39  
40  	private final boolean isSubtask;
41  
42  	public BasicIssueType(URI self, @Nullable Long id, String name, boolean isSubtask) {
43  		this.self = self;
44  		this.id = id;
45  		this.name = name;
46  		this.isSubtask = isSubtask;
47  	}
48  
49  	@Nullable
50  	public Long getId() {
51  		return id;
52  	}
53  
54  	public String getName() {
55  		return name;
56  	}
57  
58  	public boolean isSubtask() {
59  		return isSubtask;
60  	}
61  
62  	@Override
63  	public URI getSelf() {
64  		return self;
65  	}
66  
67  	/**
68  	 * Returns ToStringHelper with all fields inserted. Override this method to insert additional fields.
69  	 * @return ToStringHelper
70  	 */
71  	protected Objects.ToStringHelper getToStringHelper() {
72  		return Objects.toStringHelper(this).
73  				add("self", self).
74  				add("id", id).
75  				add("name", name).
76  				add("isSubtask", isSubtask);
77  	}
78  
79  	@Override
80  	public String toString() {
81  		return getToStringHelper().toString();
82  	}
83  
84  
85  	@Override
86  	public boolean equals(Object obj) {
87  		if (obj instanceof BasicIssueType) {
88  			BasicIssueType that = (BasicIssueType) obj;
89  			return Objects.equal(this.self, that.self)
90  					&& Objects.equal(this.id, that.id)
91  					&& Objects.equal(this.name, that.name)
92  					&& Objects.equal(this.isSubtask, that.isSubtask);
93  		}
94  		return false;
95  	}
96  
97  	@Override
98  	public int hashCode() {
99  		return Objects.hashCode(self, id, name, isSubtask);
100 	}
101 }