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 java.net.URI;
25  
26  /**
27   * Complete information about a single issue type defined in JIRA
28   *
29   * @since v0.1
30   */
31  public class IssueType implements AddressableEntity, NamedEntity, IdentifiableEntity<Long> {
32      private final URI self;
33      private final Long id;
34      private final String name;
35      private final boolean isSubtask;
36      private final String description;
37      private final URI iconUri;
38  
39      public IssueType(URI self, Long id, String name, boolean isSubtask, String description, URI iconUri) {
40          this.self = self;
41          this.id = id;
42          this.name = name;
43          this.isSubtask = isSubtask;
44          this.description = description;
45          this.iconUri = iconUri;
46      }
47  
48      @Override
49      public Long getId() {
50          return id;
51      }
52  
53      @Override
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      public String getDescription() {
68          return description;
69      }
70  
71      public URI getIconUri() {
72          return iconUri;
73      }
74  
75      protected Objects.ToStringHelper getToStringHelper() {
76          return Objects.toStringHelper(this)
77                  .add("self", self)
78                  .add("id", id)
79                  .add("name", name)
80                  .add("isSubtask", isSubtask)
81                  .add("description", description)
82                  .add("iconUri", iconUri);
83      }
84  
85      @Override
86      public String toString() {
87          return getToStringHelper().toString();
88      }
89  
90      @Override
91      public boolean equals(Object obj) {
92          if (obj instanceof IssueType) {
93              IssueType that = (IssueType) obj;
94              return Objects.equal(this.self, that.self)
95                      && Objects.equal(this.id, that.id)
96                      && Objects.equal(this.name, that.name)
97                      && Objects.equal(this.isSubtask, that.isSubtask)
98                      && Objects.equal(this.description, that.description)
99                      && Objects.equal(this.iconUri, that.iconUri);
100         }
101         return false;
102     }
103 
104     @Override
105     public int hashCode() {
106         return Objects.hashCode(self, id, name, isSubtask, description, iconUri);
107     }
108 
109 }