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.ExpandableResource;
20  import com.atlassian.jira.rest.client.api.OptionalIterable;
21  import com.google.common.base.Objects;
22  
23  import javax.annotation.Nullable;
24  import java.net.URI;
25  import java.util.Collection;
26  
27  /**
28   * Complete information about single JIRA project.
29   * Many REST resources instead include just @{}BasicProject
30   *
31   * @since v0.1
32   */
33  public class Project extends BasicProject implements ExpandableResource {
34  
35      @Nullable
36      private final Iterable<String> expandos;
37      @Nullable
38      private final String description;
39      private final BasicUser lead;
40      @Nullable
41      private final URI uri;
42      private final Collection<Version> versions;
43      private final Collection<BasicComponent> components;
44      private final OptionalIterable<IssueType> issueTypes;
45      private final Collection<BasicProjectRole> projectRoles;
46  
47      public Project(final Iterable<String> expandos, URI self, String key, Long id, String name, String description, BasicUser lead, URI uri,
48                     Collection<Version> versions, Collection<BasicComponent> components,
49                     OptionalIterable<IssueType> issueTypes, Collection<BasicProjectRole> projectRoles) {
50          super(self, key, id, name);
51          this.expandos = expandos;
52          this.description = description;
53          this.lead = lead;
54          this.uri = uri;
55          this.versions = versions;
56          this.components = components;
57          this.issueTypes = issueTypes;
58          this.projectRoles = projectRoles;
59      }
60  
61      /**
62       * @return description provided for this project or null if there is no description specific for this project.
63       */
64      @Nullable
65      public String getDescription() {
66          return description;
67      }
68  
69      /**
70       * @return the person who leads this project
71       */
72      public BasicUser getLead() {
73          return lead;
74      }
75  
76      /**
77       * @return user-defined URI to a web page for this project, or <code>null</code> if not defined.
78       */
79      @Nullable
80      public URI getUri() {
81          return uri;
82      }
83  
84      /**
85       * @return versions defined for this project
86       */
87      public Iterable<Version> getVersions() {
88          return versions;
89      }
90  
91      /**
92       * @return components defined for this project
93       */
94      public Iterable<BasicComponent> getComponents() {
95          return components;
96      }
97  
98      /**
99       * Getter for issueTypes
100      *
101      * @return the issueTypes defined for this project
102      */
103     public OptionalIterable<IssueType> getIssueTypes() {
104         return issueTypes;
105     }
106 
107     /**
108      * @return basic definition of this project's roles.
109      */
110     public Iterable<BasicProjectRole> getProjectRoles() {
111         return projectRoles;
112     }
113 
114     @Override
115     public Iterable<String> getExpandos() {
116         return expandos;
117     }
118 
119     /**
120      * {@inheritDoc}
121      */
122     @Override
123     protected Objects.ToStringHelper getToStringHelper() {
124         return super.getToStringHelper().
125                 add("description", description).
126                 add("lead", lead).
127                 add("uri", uri).
128                 add("components", components).
129                 add("issueTypes", issueTypes).
130                 add("versions", versions);
131     }
132 
133     @Override
134     public boolean equals(Object o) {
135         if (o instanceof Project) {
136             Project that = (Project) o;
137             return super.equals(that)
138                     && Objects.equal(this.lead, that.lead)
139                     && Objects.equal(this.uri, that.uri)
140                     && Objects.equal(this.description, that.description)
141                     && Objects.equal(this.components, that.components)
142                     && Objects.equal(this.issueTypes, that.issueTypes)
143                     && Objects.equal(this.versions, that.versions);
144         }
145         return false;
146     }
147 
148     @Override
149     public int hashCode() {
150         return Objects.hashCode(super.hashCode(), description, lead, uri);
151     }
152 }