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.atlassian.jira.rest.client.api.AddressableEntity;
20  import com.atlassian.jira.rest.client.api.IdentifiableEntity;
21  import com.atlassian.jira.rest.client.api.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  	 *
70  	 * @return ToStringHelper
71  	 */
72  	protected Objects.ToStringHelper getToStringHelper() {
73  		return Objects.toStringHelper(this).
74  				add("self", self).
75  				add("id", id).
76  				add("name", name).
77  				add("isSubtask", isSubtask);
78  	}
79  
80  	@Override
81  	public String toString() {
82  		return getToStringHelper().toString();
83  	}
84  
85  
86  	@Override
87  	public boolean equals(Object obj) {
88  		if (obj instanceof BasicIssueType) {
89  			BasicIssueType that = (BasicIssueType) obj;
90  			return Objects.equal(this.self, that.self)
91  					&& Objects.equal(this.id, that.id)
92  					&& Objects.equal(this.name, that.name)
93  					&& Objects.equal(this.isSubtask, that.isSubtask);
94  		}
95  		return false;
96  	}
97  
98  	@Override
99  	public int hashCode() {
100 		return Objects.hashCode(self, id, name, isSubtask);
101 	}
102 }